WPF GridView Telerik - Application memory issue - wpf

I have the following memory issue when sorting, filtering, grouping, pagging...:
I open the task manager for monitoring my app's memory, after load all data (like 500 records with 90 columns) the app's memory was like 150mb, then every time I repeat an action (I tried with reordering with any column) the memory increase, increase, increase and NEVER RELEASE
I tried the same test case with examples, and after load some memory the GC free the unused one.
Plesae helps, I will apreciate any tips.
Code
<telerik:RadGridView Name="dataGrid" Margin="4" Grid.Row="3" ItemsSource="{Binding Items}" IsReadOnly="True" SelectionMode="Extended" AlternationCount="2" AlternateRowBackground="LightGray" FrozenColumnCount="{Binding FrozenColumnIndex}" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed" view:GridViewHeaderMenu.IsEnabled="True" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
<telerik:RadGridView.Columns>
<view:NumberColumn Header="#" Width="50" DataPager="{Binding ElementName=radDataPager1}" />
<telerik:GridViewDataColumn Header="Col1" HeaderTextAlignment="Center" DataType="{x:Type System:String}" DataMemberBinding="{Binding Value1}" view:GridColumnToolTip.TextTooltip="{Binding DataContext.ColumnsDescription.Value1ColumnTooltip, ElementName=userControl}"/>
<telerik:GridViewDataColumn Header="Col2" HeaderTextAlignment="Center" DataType="{x:Type System:Int32}" DataMemberBinding="{Binding Value2}" view:GridColumnToolTip.TextTooltip="{Binding DataContext.ColumnsDescription.Value2ColumnTooltip, ElementName=userControl}"/>
<telerik:GridViewDataColumn Header="Col3" HeaderTextAlignment="Center" DataType="{x:Type System:Double}" DataMemberBinding="{Binding Value3}" DataFormatString="N3" view:GridColumnToolTip.TextTooltip="{Binding DataContext.ColumnsDescription.Value3ColumnTooltip, ElementName=userControl}"/>
<telerik:GridViewDataColumn Header="Col Hide/Show Binding" HeaderTextAlignment="Center" DataType="{x:Type System:String}" DataMemberBinding="{Binding Value4}" IsVisible="{Binding IsIndividual}" view:GridColumnToolTip.TextTooltip="{Binding DataContext.ColumnsDescription.Value4ColumnTooltip, ElementName=userControl}"/>
<!--other 90 columns-->
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<StackPanel Orientation="Horizontal" Grid.Row="4" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center">
<telerik:RadDataPager x:Name="radDataPager1" PageSize="20" DisplayMode="All" Source="{Binding Items, ElementName=dataGrid}"
IsTotalItemCountFixed="True" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock TextWrapping="Wrap" Margin="8,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="10.667"><Run Text="Ta"/><Run Language="es-es" Text="maño de página:"/></TextBlock>
<telerik:RadNumericUpDown NumberDecimalDigits="0" Value="{Binding PageSize, ElementName=radDataPager1, Mode=TwoWay}" Minimum="1" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="4,0,0,0"/>
</StackPanel>

Related

WPF DataGrid Master/Detail: How to show Master property within Detail that's within a different ItemSource

I have an object hierarchy of this: Orders have Allocations. My DataGrid has an ItemSource of Orders which then shows some details of each order in each grid row. Upon clicking on a grid row, a details pane comes up with additional details including a list of Allocations for each order. What I need to do is to somehow reference back to the Master record and pull a bit of detail (which would end up repeating) for each allocation. If I try to RelativeSource back to the DataGrid, I cannot refer to the property since that source is a whole collection and I need to get the value off of the item of that collection.
Below is a simplified version of the XAML I'm using. Basically, I need to bind to QuantityTypeDescription that's in the master record from each Allocation item in the child (Order) record.
<DataGrid ItemsSource="{Binding Orders}" AutoGenerateColumns="False" IsReadOnly="True" HorizontalScrollBarVisibility="Auto">
<DataGrid.Columns>
<DataGridTextColumn Header="Trade" Binding="{Binding TransactionTypeDescription}" Width="*"/>
<DataGridTextColumn Header="Adjustment" Binding="{Binding QuantityTypeDescription}" Width="Auto"/>
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<!--Order Summary-->
<StackPanel Orientation="Vertical">
<StackPanel Background="DarkSlateGray" Orientation="Vertical">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="{Binding TransactionTypeDescription}" FontWeight="Bold" Margin="5,0,0,0" FontSize="14" Foreground="White"/>
</StackPanel>
<TextBlock Name="Name" Text="{Binding SecurityName}" HorizontalAlignment="Center" FontWeight="Bold" Foreground="White" Background="DarkSlateGray"/>
</StackPanel>
<StackPanel Orientation="Vertical">
<ItemsControl ItemsSource="{Binding Allocations}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
NOTE: Here I need to get back up one level to get QuantityTypeDescription
<!--<TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=DataGrid, AncestorLevel=1}, Path=QuantityTypeDescription}" Margin="5,0,0,0"/>-->
<TextBlock Text="{Binding Amount}" Margin="5,0,0,0"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</StackPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
Use ElementName Binding to refer to your main DataGrid's SelectedItem
<DataGrid Name="MainDataGrid" ItemsSource="{Binding Orders}" AutoGenerateColumns="False" IsReadOnly="True" HorizontalScrollBarVisibility="Auto">
<DataGrid.Columns>
<DataGridTextColumn Header="Trade" Binding="{Binding TransactionTypeDescription}" Width="*"/>
<DataGridTextColumn Header="Adjustment" Binding="{Binding QuantityTypeDescription}" Width="Auto"/>
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<!--Order Summary-->
<StackPanel Orientation="Vertical">
<StackPanel Background="DarkSlateGray" Orientation="Vertical">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="{Binding TransactionTypeDescription}" FontWeight="Bold" Margin="5,0,0,0" FontSize="14" Foreground="White"/>
</StackPanel>
<TextBlock Name="Name" Text="{Binding SecurityName}" HorizontalAlignment="Center" FontWeight="Bold" Foreground="White" Background="DarkSlateGray"/>
</StackPanel>
<StackPanel Orientation="Vertical">
<ItemsControl ItemsSource="{Binding Allocations}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding ElementName=MainDataGrid,Path=SelectedItem.QuantityTypeDescription}" Margin="5,0,0,0"/>
<TextBlock Text="{Binding Amount}" Margin="5,0,0,0"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</StackPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>

Accessing Telerik Silverlight RadGridView from Button on Group header

I have a RadGridView, that groups its contents.
I have a Button on the group header
When I click on the button (btnSave) I would like to get access to the group to read the group key.
What can I put in the Click of btnSave to accomplish this?
<telerik:RadGridView x:Name="grdNotams" Grid.Row="1" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed" ShowGroupPanel="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn UniqueName="colNewStatus" DataMemberBinding="{Binding NewStatus}" Header="New Status" IsFilterable="False" IsSortable="False">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<telerik:RadRadioButton Content="C" Width="30" IsChecked="{Binding NewStatus, Mode=TwoWay, Converter={StaticResource StringToBooleanConverter},ConverterParameter=C}" GroupName="{Binding RadioButtonName}"/>
<telerik:RadRadioButton Content="M" Width="30" Margin="5,0,0,0" IsChecked="{Binding NewStatus, Mode=TwoWay, Converter={StaticResource StringToBooleanConverter},ConverterParameter=M}" GroupName="{Binding RadioButtonName}"/>
<telerik:RadRadioButton Content="I" Width="30" Margin="5,0,0,0" IsChecked="{Binding NewStatus, Mode=TwoWay, Converter={StaticResource StringToBooleanConverter},ConverterParameter=I}" GroupName="{Binding RadioButtonName}"/>
</StackPanel>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="Status" UniqueName="colStatus" DataMemberBinding="{Binding Model.Status, Converter={StaticResource StatusConverter}}" HeaderTextAlignment="Center" TextAlignment="Center" IsFilterable="False" IsSortable="False"/>
<telerik:GridViewDataColumn Header="Trip #" UniqueName="colTripNumber" DataMemberBinding="{Binding Model.TripNumber}" HeaderTextAlignment="Center" TextAlignment="Center" IsFilterable="False" IsSortable="False"/>
<telerik:GridViewDataColumn Header="Date" UniqueName="colDate" DataMemberBinding="{Binding Model.DepartureTime}" DataFormatString="d" HeaderTextAlignment="Center" TextAlignment="Center" IsFilterable="False" IsSortable="False"/>
</telerik:RadGridView.Columns>
<telerik:RadGridView.GroupHeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<telerik:RadButton x:Name="btnSave" Click="btnSave_Click">
<StackPanel Orientation="Vertical">
<Image Source="../images/save.jpg" Height="30" Width="30" HorizontalAlignment="Center"/>
<TextBlock TextAlignment="Center" TextWrapping="Wrap">Update</TextBlock>
</StackPanel>
</telerik:RadButton>
<TextBlock Text="{Binding Group.Key}" FontSize="14" FontWeight="Bold" FontStyle="{Binding EarliestNotamDepartureTime, Converter={StaticResource DateTimeToItalicsConverter}}" TextWrapping="Wrap" VerticalAlignment="Center" Padding="5"/>
</StackPanel>
</DataTemplate>
</telerik:RadGridView.GroupHeaderTemplate>
<telerik:RadGridView.GroupDescriptors>
<telerik:GroupDescriptor Member="NotamGroup" >
</telerik:GroupDescriptor>
<telerik:GroupDescriptor Member="Model.NotamText">
</telerik:GroupDescriptor>
</telerik:RadGridView.GroupDescriptors>
</telerik:RadGridView>
Figured it out.
The DataContext has the information I needed in the form of the GroupViewModel class.
Code
private void btnSave_Click(object sender, RoutedEventArgs e)
{
GroupViewModel vm = ((RadButton)sender).DataContext as GroupViewModel;
}

Datagrid column width binding to another column in another datagrid

I have a requirement to keep all the column widths matching accross several datagrids. As I have things defined the column can grow as required as the user enters larger numbers. As this happens the sibling table columns get out of alighment and their width needs to keep pace with the column where the data is being entered. Because of the number of columns I can't really use fixed width, although that may be the only way.
Here is a stripped down defination of the datagrid for example. All table are defined in the same fashion and of course have many more columns. Any ideas would be appriciated.
<DataGrid Grid.Row="0" Style="{StaticResource BaseAFGrid}" HorizontalAlignment="Stretch" x:Name="gridBilanActif"
VerticalAlignment="Top" Margin="5,5,0,0">
<DataGrid.Columns>
<DataGridTemplateColumn IsReadOnly="False" Header="Nom" Width="260" CanUserSort="False" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<TextBox Margin="{Binding Level, Converter={StaticResource LevelConverter}}"
x:Name="txtTitreA" Style="{StaticResource AFTextbox}"
IsReadOnly="{Binding TitreEstNonmodifiable}"
Text="{Binding Nom, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
Width="200" HorizontalAlignment="Left"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="False" Header="1" Width="Auto" MinWidth="55" CanUserSort="False" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<TextBox x:Name=" colPeriode1A" Style="{StaticResource MilierDoubleTextBoxAF}"
CValidation:TextboxValidator.IsFloating="True" CValidation:TextboxValidator.MaxDecimal="2"
IsReadOnly="{Binding HasChildren}" TextChanged="colPeriode1A_TextChanged"
Text="{Binding P1_Bilan, Mode=TwoWay, UpdateSourceTrigger=LostFocus,
Converter={StaticResource CurrencyConverter}}" HorizontalAlignment="Right"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn IsReadOnly="False" Header="2" Width="Auto" MinWidth="55" CanUserSort="False" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<TextBox x:Name=" colPeriode2A" Style="{StaticResource MilierDoubleTextBoxAF}"
CValidation:TextboxValidator.IsFloating="True" CValidation:TextboxValidator.MaxDecimal="2"
IsReadOnly="{Binding HasChildren}"
Text="{Binding P2_Bilan, Mode=TwoWay, UpdateSourceTrigger=LostFocus,
Converter={StaticResource CurrencyConverter}}" HorizontalAlignment="Right"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>

silverlight printing using davidpoll.com collection printer

I am working in a Silverlight 4 application. I have a datagrid that I would like to print. I am trying to use davidpoll printing functionality
Currently, I am printing just the datagrid header, but no items are being printed
<SLaB:CollectionPrinter x:Name="printer" ItemsSource="{Binding CurrentSearchView}" >
<SLaB:CollectionPrinter.BodyTemplate>
<DataTemplate>
<sdk:DataGrid x:Name="dgResults" VerticalAlignment="Stretch" SelectionMode="Single" HorizontalAlignment="Stretch" AutoGenerateColumns="False" ItemsSource="{Binding CurrentSearchView}" IsReadOnly="True" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" Margin="10" FontSize="12" FontFamily="Segoe UI" >
<sdk:DataGrid.Columns>
<sdk:DataGridTextColumn Binding="{Binding PeopleId}" Header="People ID" Width="150"/>
<sdk:DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="*" MinWidth="80"/>
<sdk:DataGridTemplateColumn Header="FQ" Width="80">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel x:Name="spFq" Background="{Binding FqBackground}" Margin="2">
<Image Source="{Binding FqImagePath}" Margin="4" Height="24" Width="24"/>
</StackPanel>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTemplateColumn Header="LQ" Width="80" CellStyle="{StaticResource BrowseQualityCellStyle}">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel x:Name="spLq" Orientation="Horizontal" Background="{Binding LqBackground}" Margin="2" >
<myControls:PlayButtonControl x:Name="playControl" Margin="4" Height="24" Width="24" />
<Image Source="{Binding LqImagePath}" Margin="4" Height="16" Width="16"/>
</StackPanel>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTextColumn Binding="{Binding Format}" Header="Format" Width="Auto"/>
<sdk:DataGridTextColumn Binding="{Binding Duration}" Header="Duration" Width="Auto"/>
<sdk:DataGridTextColumn Binding="{Binding Attachment}" Header="Attachment" Width="Auto"/>
<sdk:DataGridTextColumn Binding="{Binding Restore}" Header="Restore" Width="Auto"/>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
</DataTemplate>
</SLaB:CollectionPrinter.BodyTemplate>
</SLaB:CollectionPrinter>
And here is the button command
<Button Command="{Binding PrintCommand, ElementName=printer}">Print</Button>
Note that both, the collectionprinter and datagrid are referencing the same property CurrentSearchView, which is a PagedCollectionView. I think that my problem lies there, maybe I am not able to used this kind of collection (i also try with an observable collection and found the same results), or my bindings are wrong (having both controls referencing the same property, doesn't seem right)
Any help will be greatly appreciated.
Thanks
I have found the problem. I needed to set the binding of the datagrid to "CurrentItems"
<sdk:DataGrid x:Name="dgResults" VerticalAlignment="Stretch" SelectionMode="Single" HorizontalAlignment="Stretch" AutoGenerateColumns="False" ItemsSource="{Binding CurrentItems}" IsReadOnly="True" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled" Margin="10" FontSize="12" FontFamily="Segoe UI" >

WPF 3.5 nested datagrid row details not showing in Visual Tree

So I build a nice nested datagrid that look something like this:
<dg:DataGrid x:Name="mainGrid"
AutoGenerateColumns="False"
CanUserAddRows="False"
AreRowDetailsFrozen="True"
CanUserReorderColumns="False"
CanUserResizeColumns="True"
CanUserResizeRows="False"
SelectionUnit="FullRow"
RowDetailsVisibilityMode="VisibleWhenSelected">
<dg:DataGrid.Columns>
<dg:DataGridTemplateColumn CanUserResize="False" CanUserSort="False" Width="36" IsReadOnly="False">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="+" Width="28" Height="28" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}"/>
</Grid>
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn Header="Name" IsReadOnly="True" Width="582">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="5" VerticalAlignment="Center" Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=Default}" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn Header="Status" IsReadOnly="True" Width="150">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="5" VerticalAlignment="Center" Text="{Binding Status, Mode=TwoWay, UpdateSourceTrigger=Default}" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridCheckBoxColumn Binding="{Binding IsSelected}"/>
</dg:DataGrid.Columns>
<dg:DataGrid.RowDetailsTemplate>
<DataTemplate>
<dg:DataGrid x:Name="scondaryDatagrid" Margin="29,0,0,0"
AutoGenerateColumns="False"
CanUserAddRows="False"
AreRowDetailsFrozen="True"
CanUserReorderColumns="False"
CanUserResizeColumns="True"
CanUserResizeRows="False"
SelectionUnit="Cell"
RowDetailsVisibilityMode="VisibleWhenSelected"
ItemsSource="{Binding Grades, Mode=TwoWay}">
<dg:DataGrid.Columns>
<dg:DataGridTemplateColumn CanUserResize="False" CanUserSort="False" Width="32" IsReadOnly="True">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="+" Width="28" Height="28" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn CanUserResize="False" CanUserSort="False" Width="32" IsReadOnly="True">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Center" HorizontalContentAlignment="Center" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn Header="Name" IsReadOnly="True" Width="550">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="5" Text="{Binding Name, Mode=TwoWay}" VerticalAlignment="Center" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
</dg:DataGrid.Columns>
<dg:DataGrid.RowDetailsTemplate>
<DataTemplate>
<dg:DataGrid Margin="25,0,0,0"
AutoGenerateColumns="False"
CanUserAddRows="False"
AreRowDetailsFrozen="True"
CanUserReorderColumns="False"
CanUserResizeColumns="True"
CanUserResizeRows="False"
SelectionUnit="Cell"
ItemsSource="{Binding Notes, Mode=TwoWay}">
<dg:DataGrid.Columns>
<dg:DataGridTemplateColumn CanUserResize="False" CanUserSort="False" Width="32" IsReadOnly="True">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}" VerticalAlignment="Center" HorizontalAlignment="Center" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
<dg:DataGridTemplateColumn Header="Note" IsReadOnly="True" Width="550">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="5" Text="{Binding Note, Mode=TwoWay}" VerticalAlignment="Center" />
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
</dg:DataGridTemplateColumn>
</dg:DataGrid.Columns>
</dg:DataGrid>
</DataTemplate>
</dg:DataGrid.RowDetailsTemplate>
</dg:DataGrid>
</DataTemplate>
</dg:DataGrid.RowDetailsTemplate>
</dg:DataGrid>
Due to the RowDetailsVisibilityMode property when it is set to VisibleWhenSelected, the Node DataGridDetailsPresenter for the rows have 0 children. When the property is set to Visible I can see the DataGridDetailsPresenter children.
How can I force the inclusion of all the nodes in the Visual tree for when the RowDetailsVisibilityMode property is VisibleWhenSelected?
Any input is greatly appreciated.
What are you trying to accomplish?
Unless the the RowDetails are visible they would not be in the Visual Tree unless could force their creation by setting the RowDetailsVisibilityMode to Visible but setting the RowDetails DataGrid visibility to Collapsed. This may not work. I don't know if the DataGrid would be in the Visual Tree if set to Collapsed in 3.5.

Resources