Is there a way to raise PropertyChanged when IsGroupBy changes on a FieldLayout? I have some labels whose Visibilities I want to bind to IsGroupBy using a DataTrigger. The initial rendering works fine, however, when the user groups/degroups on the XamDataGrid, the DataTrigger is not reevaluated because no PropertyChanged was raised.
Definition of DataTrigger mentioned:
<DataTrigger Binding="{Binding IsGroupBy, ElementName=itemType, Mode=TwoWay}" Value="True">
<Setter Property="Label.Visibility" Value="Collapsed" />
</DataTrigger>
Definition of "itemType":
<igDP:FieldSortDescription x:Name="itemType" IsGroupBy="True" Direction="Ascending" FieldName="Item_Type"/>
Thanks!
Hello Daniel,
I can suggest you add the following DataTemplate to your XamDataGrid's Resources:
<DataTemplate DataType="{x:Type igDP:FieldLayoutGroupByInfo}" />
Hope this helps you.
I am satisfied with the solution, thanks Stefan. I am using a hierarchical grid :). It works fine, however, in the GroupByArea, the level 2 class name is displayed when I group by a column:
lvl2Class name ----- Type
where Type is the GroupedByField
Can you advise on how to remove the subclass name from GroupByArea
Since the grouping is based on the Record’s values, if the some value doesn’t occur in any of the records the XamDataGrid won’t be able to create an empty Group for it. If the type of the underlying object is Enum or some other restricted type there will be a way of achieving your goal. If you want I can log a product idea for this functionality, which could be implemented in some of our feature versions.
Looking forward for your reply.
Stefan, this works great for what I asked! On a slightly different note, I need to set my label's visibility based on more than one condition. The first condition being the IsGroupBy property, the second condition being a property on the ViewModel.
To achieve the desired effect, I've done the following:
<Label.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding ViewModelProperty}" Value="True" >
<Setter Property="Label.Visibility" Value="{Binding ElementName=itemType, Path=Field.IsGroupBy,
Converter={StaticResource boolToVisibilityConverter}}" />
<DataTrigger Binding="{Binding Trigger}" Value="False" >
</Style.Triggers>
</Style>
</Label.Style>
For some context, I want to display a "dummy" label when the user groups by a column (that inherently will contain up to 4 different values) and one of those 4 values isn't listed in the data, so the subgrouping would never appear. So, I always want to show the user the number of items for each value, even if the number of items is 0.
Column1 Column2 Column3
Potential values for Column1: Red, Green, Yellow
Group by Column1....
User sees the subheadings of:"Red (2 items)"
"Green (5 items)"
"Yellow (0 items)"
I believe this is outside the context of my original question, so will mark it answered. If there is an easier way than show/hide dummy label based on # of items > 0 && IsGroupBy Column1 = true, then let me know :). Thanks.
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I created Style for the LabelPresenter and bound its Visibility to the IsGroupByProeprty and using converter I set this Property. Please let me know if his helps you or you need further assistance on this matter.