I have a sorted data grid. By default it displays everything collapsed.
By handling the InitializeRecord event in the code-behind file I can set Record.IsExpanded = true and get the grid to display everything expanded at startup.
How can I do the same thing in XAML?
Thanks,
- Dave
Hello Dave,
You can create a style for the DataRecordPresenter and add a setter for IsExpanded property to true.
You can also use a EventTrigger and use igDP:XamDataGrid.Loaded event to expand them with the same setter.
Hope this helps,
Alex.
Thanks for the quick reply!
Here's a more basic question: How do I get to the DataRecordPresenter properly?
I've implemented the example from the Help page that puts buttons in cells of a data grid.
I've created a style as follows:
<Style TargetType="{x:Type igDP:DataRecordPresenter}">
<Setter Property="IsEnabled" Value="True" />
</Style>
Shouldn't this automatically apply to all igDP:DataRecordPresenter objects in the system?
Or do I need to specify an x:Key in the Style? If so, where in the XamDataGrid definition to I reference this key?
You should not set key to the style so that it would be applied by default. Also, if you have set a theme for the XamDataPresenter, you should put that style in the Resources section of the XamDataGrid itself, because WPF support only one local style.
Still not working.
Here's my XAML file:
<
Window x:Class="DataPresenterExample.ButtonCell" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igDP="http://infragistics.com/DataPresenter" Title="ButtonCell" Height="600" Width="600">
</
Window>
I am not quite sure what you are trying to achieve with this setter:
True is the default value of that property.
Am I missing something?
This was my attempt to implement your first suggestion.
I can make the Data Grid come up Expanded if I handle the InitializeRecord event in the code-behind file and set the Record.IsEpanded property to True.
What I'm looking for is a way to do this in XAML, so I can keep my code-behind file as simple as possible.
(I'm using Dependency Injection with the M-V-VM pattern to allow unit tests to be as complete as possible.)
I can't figure out how to get at the correct instances of the Record classes from XAML without handling an event.
This may be more of a WPF question rather then a specifically Infragistics question.
Dave,
Test this and let me know if that works for you:
<EventTrigger RoutedEvent="igDP:XamDataGrid.Loaded">
<BeginStoryboard>
<Storyboard>
<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="IsExpanded" Duration="0:0:0">
<BooleanAnimationUsingKeyFrames.KeyFrames>
<BooleanKeyFrameCollection>
<DiscreteBooleanKeyFrame Value="True"/>
</BooleanKeyFrameCollection>
</BooleanAnimationUsingKeyFrames.KeyFrames>
</BooleanAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
Regards,
Alex --
I tried the following:
1. ) I embedded the the Event Trigger XAML (from your post) within a Style Element in the Window.Resources area that is being applied to all igDP:DataRecordPresenter object.
This does not seem change anything.
2.) I embedded the Event Trigger XAML (from your post) within a <igDP:XamDataGrid.Triggers> Element within the <igDP:XamDataGrid> declaration. This time I got a compile error because the compiler couldn't figure out what I meant by the "IsExpanded" property.
When I handle the InitializeRecords event in the code-behind I set the IsEnabled property of DataPresenter.Record.
How do I get access to DataPresenter.Record in the XAML file?
Is there some way to get here from <igDP:XamDataGrid.Records> or
<igDP:XamDataGrid.ViewSettings>?
I had a similar experience with this same project. Following the example in the Help I was handling the FieldLayoutInitialized event so I could Collapse the Visibility of the field that was used as the grouping criteria.
I saw that since I was already looking at the first FieldLayout in the XAML all I had to do was declare a Field object with the Name of the field to be collapsed. Thus, I no longer needed to do this in the code-behind file.
I'm looking to do something similar to this for the DataPresenter.Record.IsExpanded, but I can't figure out how to get access to the DataPresenter object in XAML.