template picker with accordion

399
2
06-21-2010 02:43 AM
Bende_Vries
New Contributor
If, during editing,  you use layers where the amount of unique value info's in drawing info is big then the standard template picker (stackpanel with series of textblock+templatepanel) can become quite large. I tried to change the default templatepicker to make use of an accordion. So that only one layer's symbols are visible at one time and such reducing the space the templatepicker occupies. I did not manage to get this to work properly. Has anybody else (hopefully with more templating knowledge) tried this ?

I tried to replace the StackPanel with an Accordion and played around with AccordionItems, etc. but this did not work good.

<Style x:Key="TemplatePickerGrid8x8" TargetType="esri:TemplatePicker">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="esri:TemplatePicker">
                    <ItemsControl ItemsSource="{TemplateBinding TemplateGroups}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="{Binding Name}" Foreground="White" FontWeight="Bold"/>
                                    <esriPrimitives:TemplatePanel Templates="{Binding Templates}" StackCount="8" StackDirection="Vertical">
                                        <esriPrimitives:TemplatePanel.ItemTemplate>
                                            <DataTemplate>
                                                <Grid>
                                                    <Button HorizontalContentAlignment="Center" Margin="2" Command="{Binding Editor.Add}" CommandParameter="{Binding TypeID}" ToolTipService.ToolTip="{Binding Name}">
                                                        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical">
                                                            <esriPrimitives:SymbolDisplay Height="20" Width="20" Symbol="{Binding Symbol}" />
                                                        </StackPanel>
                                                    </Button>
                                                </Grid>
                                            </DataTemplate>
                                        </esriPrimitives:TemplatePanel.ItemTemplate>
                                    </esriPrimitives:TemplatePanel>
                                </StackPanel>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor
Create a ComboBox and populate it with an entry for each featurelayer. On the SelectionChanged event, set the TemplatePicker.LayersIDs property to the ID of the selected featurelayer. That way you get a simple way of first selecting what layer you want to edit against, and secondly pick the template for that layer.
0 Kudos
Bende_Vries
New Contributor
Thanks Morten, good idea. I will do it that way.
0 Kudos