I am trying to create view using Telerik for WPF. The View should present collection loaded in VM after button click. Every element from collection is inheriting from base class:
public class BindableProfileData : BindableBase
{
private ProfileItem _profileModel;
private BindableDPDataItem _dataModel;
public int Row
{
get { return _profileModel.DrawingSettings.Row; }
}
public int Column
{
get
{
return _profileModel.DrawingSettings.Column;
}
}
public int RowSpan
{
get { return _profileModel.DrawingSettings.RowSpan; }
}
public int ColumnSpan
{
get { return _profileModel.DrawingSettings.ColumnSpan; }
}
}
so for example in collection may appear object of
BarContainer : BindableProfileData {}
Now to present content i created that view:
<Grid>
<FrameworkElement.Resources>
<DataTemplate x:Key="ItemTemplate" >
<TextBlock Text="{Binding Name}" />
</DataTemplate>
<DataTemplate x:Key="ContentTemplate">
<StackPanel>
<TextBlock Text="{Binding Row, StringFormat='Row: {0}'}"/>
<TextBlock Text="{Binding Column, StringFormat='Column: {0}'}"/>
<TextBlock Text="{Binding RowSpan, StringFormat='RowSpan: {0}'}"/>
<TextBlock Text="{Binding ColumnSpan, StringFormat='ColumnSpan: {0}'}"/>
</StackPanel>
</DataTemplate>
</FrameworkElement.Resources>
<Grid>
<telerik:RadTileView x:Name="xTileView"
ItemTemplate="{StaticResource ItemTemplate}"
ContentTemplate="{StaticResource ContentTemplate}"
ItemsSource="{Binding SelectedCategory}"
IsAutoScrollingEnabled="True"
ColumnWidth="500"
RowHeight="300">
<telerik:RadTileView.ItemsPanel>
<ItemsPanelTemplate>
<controlls:MultipleRowsAndColumnsPanel RowsCount="4" ColumnsCount="3"/>
</ItemsPanelTemplate>
</telerik:RadTileView.ItemsPanel>
<telerik:RadTileView.ItemContainerStyle>
<Style TargetType="telerik:RadTileViewItem">
<Setter Property="controlls:TileViewAttachedProperties.Row" Value="{Binding Row}"/>
<Setter Property="controlls:TileViewAttachedProperties.Column" Value="{Binding Column}"/>
<Setter Property="controlls:TileViewAttachedProperties.RowSpan" Value="{Binding RowSpan}"/>
<Setter Property="controlls:TileViewAttachedProperties.ColumnSpan" Value="{Binding ColumnSpan}"/>
</Style>
</telerik:RadTileView.ItemContainerStyle>
</telerik:RadTileView>
</Grid>
</Grid>
Which uses helpers from telerik guides (MultipleRowsAndColumnsPanel, TileViewAttachedProperties)
I have two problems. First why view not appears after Collection change.
When I cut:`
<telerik:RadTileView.ItemsPanel>
<ItemsPanelTemplate>
<controlls:MultipleRowsAndColumnsPanel RowsCount="4" ColumnsCount="3"/>
</ItemsPanelTemplate>
</telerik:RadTileView.ItemsPanel>
` from code and paste it again (Visual Studio edit and run) view appears just How I want it to be. So it looks like ItemsPanel not reacting on collection Change, but how to fix it? And the second question how can I specify different templates for different classes in collection. I found similar post but I don't know how to do it with RadViewTableItem because it has two elements (ItemTemplate and ContentTemplate) usually specified in RadTileView.
Any advice whould be very helpfull for me. Thank you :)