0

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 :)

Community
  • 1
  • 1
Maciek
  • 61
  • 1
  • 8
  • 1
    You could have different DataTemplates without `x:Key`, but with their `DataType` property set. Thus they would be applied automatically. See [Data Templating Overview](https://msdn.microsoft.com/en-us/library/ms742521(v=vs.110).aspx) on MSDN. – Clemens May 11 '17 at 09:35
  • What collection are you using: `ObservableCollection`, `List`? Are you raising `INPC` when collection is changed? – XAMlMAX May 11 '17 at 11:36
  • ObservableCollection. Collection property I use prism SetProperty(ref _SelectedCategory, value), which calles OnPropertyChange. – Maciek May 11 '17 at 12:02
  • When I don't use MultipleColumnsPanel as ItemsTemplate everything works perfect, so I think that there is a problem, but I don't know how to fix it. – Maciek May 11 '17 at 12:04

0 Answers0