RowStyleSelector with TreeListViewRow Control Template to display different row types

4 posts, 0 answers
  1. Simon
    Simon avatar
    3 posts
    Member since:
    May 2012

    Posted 29 Jul 2013 Link to this post

    I am trying to supply different TreeListViewRow templates using a RowStyleSelector to show certain types of rows (GetMoreData rows) with a template that does not follow the columns, but instead displays a button which you click to get more data (more children for that row).

    The RowStyleSelector looks like :

    <local:MyGridRowStyleSelector x:Key="RowStyleSelector">
        <local:MyGridRowStyleSelector.MoreResultsRowStyle>
            <Style TargetType="telerik:TreeListViewRow"
                    x:Name="MoreResults">
                <Setter Property="telerik:TreeListViewRow.Template"
                            Value="{StaticResource MoreDataCustomRowTemplate}" />
            </Style>
        </local:MyGridRowStyleSelector.MoreResultsRowStyle>
        <local:MyGridRowStyleSelector.NormalRowStyle>
            <Style TargetType="telerik:TreeListViewRow"
                       x:Name="NormalResults">
            </Style>
        </local:MyGridRowStyleSelector.NormalRowStyle>
    </local:MyGridRowStyleSelector>


    The MoreResults TreeListViewRow Control Template is taken from Blend "Copy Template" on the TreeListViewRow but I have simply replaced the PART_DataCellsPresenter with :

    <ItemsControl x:Name="PART_DataCellsPresenter"
                                    Grid.ColumnSpan="2"
                                    Grid.Column="1"
                      ItemsSource="{Binding Path=Functions}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Button Content="{Binding}" />
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>

    I have this basic structure working and the MoreResults rows show Buttons as expected, but  there are exceptions that show up in the output window : A first chance exception of type 'System.ArgumentException' occurred in Telerik.Windows.Data.dll

    Would this be the suggested approach or is there a better way, that doesn't cause the exceptions ?
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 01 Aug 2013 Link to this post

    Hello,

    I am not sure why such an exception occurs. Have you tried to specify a Path for the Binding? Why don't you leave the DataCellsPresenter as it is and just place your <ItemsPanelTemplate>?

    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Simon
    Simon avatar
    3 posts
    Member since:
    May 2012

    Posted 05 Aug 2013 Link to this post

    fyi, your question: Why not keep telerik:DataCellsPresenter ...
    Well, this didn't render anything (a thin totally blank row - no sign of button):

    <telerik:DataCellsPresenter x:Name="PART_DataCellsPresenter" Grid.ColumnSpan="2" Grid.Column="1" IsTabStop="False"
                                ItemsSource="{Binding Path=Functions}">
     
        <telerik:DataCellsPresenter.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Button Content="XXXXXX" Width="100" HorizontalAlignment="Left" />
                </Grid>
            </DataTemplate>
            </telerik:DataCellsPresenter.ItemTemplate>
     
    </telerik:DataCellsPresenter>
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 05 Aug 2013 Link to this post

    Hello,

    Actually this is not the way to customize the TreeListViewRow. You can check the "Custom Row Layout" WPF Demo (the Silverlight equivalent can be found here). 
    Another option would be to just redefine the CellTemplate of the columns.

    How does those two options work for you?

    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top