This is a migrated thread and some comments may be shown as answers.

RowStyleSelector with TreeListViewRow Control Template to display different row types

3 Answers 140 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 29 Jul 2013, 07:07 AM
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 ?

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 01 Aug 2013, 08:48 AM
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 >>
0
Simon
Top achievements
Rank 1
answered on 05 Aug 2013, 07:17 AM
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>
0
Dimitrina
Telerik team
answered on 05 Aug 2013, 08:44 AM
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 >>
Tags
TreeListView
Asked by
Simon
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Simon
Top achievements
Rank 1
Share this question
or