I have hierarchical xamDataGrid which we would like to expand and collapse after click on button.
Also, we are using MVVM so there is no code behind.
So I found solution that we need to use IsExpanded in xaml using style for DataRecordPresenter. Something like this:
<Style TargetType ="{x:Type igDP:DataRecordPresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=DataContext.ExpandAll, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:XamDataGrid}}}" Value="True"> <Setter Property="IsExpanded" Value="True"/> </DataTrigger> <DataTrigger Binding="{Binding Path=DataContext.ExpandAll, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:XamDataGrid}}}" Value="False"> <Setter Property="IsExpanded" Value="False"/> </DataTrigger> </Style.Triggers> </Style>
Off course is not working. But when I change property to for example Background then it's works fine.
Please help us.
Hello,
Currently, this is a known issue for us. This is because of the dependency property value precedence.
When the record is expanded, the value is set locally and the style trigger cannot override the local value as the local value has a higher precedence than a style trigger. You could override this with an animation, but then you will not be able to collapse the record, this time because the Animation has a higher precedence than the local value and the style trigger. We are currently looking for an alternative way of making this possible.
OK. In that case I did new DependencyProperty as below
public static readonly DependencyProperty IsExpandedAllProperty = DependencyProperty.RegisterAttached( "IsExpandedAll", typeof(bool), typeof(ExtXamDataGrid), new UIPropertyMetadata(false, OnIsExpandedChanged));
And now my problem is solved :-)
Thanks for help
Daniel
Daniel,
Just for anyone who comes across this thread via search, you are manually expanding the records in the callback method of the dependency property, right?
Yes. It's look similar (not exactly) like below:
public static void OnIsExpandedChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e) { if (e.NewValue is bool) { XamDataGrid grid = depObj as XamDataGrid; if ((bool)e.NewValue) { foreach (DataRecord dr in grid.Records) dr.IsExpanded = true; return; } // collapse all foreach (DataRecord dr in grid.Records) dr.IsExpanded = false; } }
Is there a way to send expansion information of all nodes to viewmodel?
Hi Support Team,
Do we have a fix for this known issue in the current release (2010.2) ?
Regards,
Prasanna.
For more details on how to do it please search for Josh Smith example with IsSynchronizedWithCurrentItem