Object reference not set error, when using DataTemplate with GroupView
Hi, I am trying to load and fill a GroupView in a GroupBarItem:
syncfusion:GroupView Name="GroupView" IsListViewMode="True" ItemsSource="{Binding Items}"
syncfusion:GroupView.ItemTempla
DataTemplate
Syncfusion:GroupViewItem
/DataTemplate
/syncfusion:GroupView.ItemTemplate
/syncfusion:GroupView
But I am getting a error: NullReferenceException: Object reference not set to an instance of an object.
Am I doing something wrong here?
stacktrace:
at Syncfusion.Windows.Tools.Controls.GroupViewItem.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.UIElement.UpdateLayout()
SIGN IN To post a reply.
2 Replies
1 reply marked as answer
EM
Elakkiya Muthukumarasamy
Syncfusion Team
December 23, 2020 01:15 PM UTC
Hi Jonas,
Thank for contacting Syncfusion support.
We have checked the reported issue “Null exception thrown while using DataTemplate with GroupView” and confirmed it is a defect. We have logged a report on this and the patch for this fix is estimated to be available on 31st December, 2020.
You can track the status of this defect using the following feedback link:
Please let us know if you need any other assistance on this.
Regards,
Elakkiya
VR
Vijayalakshmi Roopkumar
Syncfusion Team
December 31, 2020 04:50 PM UTC
Hi Jonas,
Thank you for your update.
We have checked the reported behaviour using the GroupViewItem inside the ItemTemplate of the GroupView. We found on populating the ItemsSouce to GroupView, group view item created inside the item container. So when we place the GroupViewItem inside the ItemTemplate, it will be added as the child of the existing GroupViewItem which already present inside the item container. Since our GroupViewItem is working based on the logical parent and it is not a detachable control, so it tries to find the logical parent continuously, that leads to crash. So only, we are unable to define the GroupViewItem inside the ItemTemplate of the GroupView. If we add any other controls inside the ItemTemplate of the GroupView, it will be working properly.
Also we found that, ItemsControl is bound to a collection object in the given sample that is not bound to any syncfusion properties. We have modified the sample where the ItemContainerStyle property is used instead of the ItemTemplate property.
Please let us know and share some more information based on your requirement like for what purpose you have used GroupViewItem inside the ItemTemplate , it will be helpful for us to let you know a solution.
Please find the attached sample with code snippet.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/GroupBar20280622262056145871
Code snippet:[XAML]
|
<syncfusion:GroupView IsListViewMode="True" ItemsSource="{Binding GroupViewItems}" >
<syncfusion:GroupView.ItemContainerStyle>
<Style TargetType="{x:Type syncfusion:GroupViewItem}">
<Setter Property="Text" Value="Outbox"/>
<Setter Property="ToolTip" Value="Outbox"/>
<Setter Property="TextHorizontalAlignment" Value="Left"/>
<Setter Property="ImageHorizontalAlignment" Value="Right"/>
<Setter Property="ImageSource" Value="Images/Outbox.png"/>
</Style>
</syncfusion:GroupView.ItemContainerStyle>
</syncfusion:GroupView>
|
Regards
Vijayalakshmi VR
Marked as answer
SIGN IN To post a reply.