deathrace
deathrace

Reputation: 1073

split DataTemplate in different grids using ItemTemplateSelector

I am working on WPF-XAML. My requirement is : I need to add collection of Trunks(which consists of Border & TexBlocks) in a Tab. there will be 2 types of such Trunks (say RSPTrunkTemplate and ASPTrunkTemplate). now I need to add collection of Trunks of type RSPTrunkTemplate in one grid. then there will be GridSplitter and then I need to add another collection of Trunks of type ASPTrunkTemplate in another grid.

I am using ItemTemplateSelector as follows :

<Grid>
                <ItemsControl Name="TrunkList"
                              ItemsSource="{Binding RSPTrunks}"
                              ItemTemplateSelector="{StaticResource TrunkItemTemplateSelector}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel Orientation="Vertical" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                </ItemsControl>
            </Grid>

this TrunkItemTemplateSelector is as follows :

<Helpers:TrunkItemTemplateSelector x:Key="TrunkItemTemplateSelector"
                                           RSPTrunkTemplate="{StaticResource RSPTrunkTemplate}"
                                           SPTrunkTemplate="{StaticResource ASPTrunkTemplate}" />

Now, RSPTrunkTemplate should be in one grid and ASPTrunkTemplate shoulb be in another grid. How to do this. Do I have to change my approach.? I seek your help guys.

Upvotes: 0

Views: 118

Answers (1)

Dtex
Dtex

Reputation: 2623

ItemTemplateSelector, as the name suggests, is used to specify a different template for the objects inside a ItemsControl, not to do filtering. If i understand correctly you want to apply a grouping maybe this link can help you http://msdn.microsoft.com/en-us/library/ms742542.aspx

Upvotes: 1

Related Questions