I am fairly new to WPF and Telerik controls for WPF. I have been searching google, these forums, and more to try and figure out what I believe should be easy enough to do. I would like to set up a RadGridView to have a list of columns in a "style" or resource so I can use it on multiple pages. Here is an example of what I tried to do:
but the "Columns" property is read only. I tried searching for ways to add items to collections within XAML, but I could not find any ways to do this. In my mind, this seems like it should be fairly easy to acomplish, but it never truly is :P
| <Style x:Key="myGrid" TargetType="{x:Type telerik:RadGridView}"> |
| <Setter Property="Template"> |
| <Setter.Value> |
| <ControlTemplate TargetType="telerik:RadGridView"> |
| <AdornerDecorator> |
| <Border Name="PART_MasterGridContainer" Grid.Row="1" BorderThickness="1" Background="White" BorderBrush="#FF9EB6CE"> |
| <telerik:GridViewItemsControl x:Name="PART_RootItemsControl" |
| IsHierarchyRoot="{TemplateBinding IsHierarchyRoot}" |
| ParentRow="{TemplateBinding ParentRow}" |
| ScrollMode ="{TemplateBinding ScrollMode}" |
| ShowColumnHeaders="{TemplateBinding ShowColumnHeaders}" |
| ShowGroupPanel="{TemplateBinding ShowGroupPanel}" /> |
| </Border> |
| </AdornerDecorator> |
| </ControlTemplate> |
| </Setter.Value> |
| </Setter> |
| <Setter Property="ColumnsWidthMode" Value="Fill" /> |
| <Setter Property="Width" Value="Auto" /> |
| <Setter Property="Height" Value="Auto" /> |
| <Setter Property="VerticalGridlinesVisibility" Value="Hidden" /> |
| <Setter Property="telerik:RadGridView.Columns"> |
| <Setter.Value> |
| <telerik:GridViewColumnCollection> |
| <telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="Image" UniqueName="ImageName" IsGroupable="False" IsSortable="False" Width="50" CellStyle="{StaticResource ImageCell}" /> |
| <telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="ColA" UniqueName="ColA" IsGroupable="False" IsSortable="False" Width="50" /> |
| <telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="ColB" UniqueName="ColB" IsGroupable="False" IsSortable="False" Width="50" /> |
| <telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="ColC" UniqueName="ColC" IsGroupable="False" IsSortable="False" Width="50" /> |
| <telerik:GridViewDataColumn DataType="{x:Null}" HeaderText="ColD" UniqueName="ColD" IsGroupable="False" IsSortable="False" Width="50" /> |
| </telerik:GridViewColumnCollection> |
| </Setter.Value> |
| </Setter> |
| </Style> |
