How to use this stackpackan as a resource

I am just trying to get the contents of a StackPanel in a ResourceDictionary. I tried wrapping it in a data template, but did not go. Any other template? Style?

How can I extract this to a resource and then use the content in the layout of the view?

Cheers,
Berryl

xaml to move

<StackPanel x:Name="_filterByTypeOptions" Orientation="Horizontal" Margin="5, 5" >
    <RadioButton Style="{StaticResource FilterPanelRadioButtonStyle}" 
         IsChecked="{Binding ShowAllContacts, Mode=TwoWay}" 
         Content="{resx:Resx Filter_ByType_ShowAll}" ToolTip="{Resx Filter_ByType_ShowAll_ToolTip}"
         />
    // ... more of the same

</StackPanel>

UPDATE

current template

<DataTemplate x:Key="FilterTypeByTemplateControl">
    <StackPanel x:Name="_filterByTypeOptions" Orientation="Horizontal" Margin="5, 5" >
        <RadioButton Style="{StaticResource FilterPanelRadioButtonStyle}" 
                     IsChecked="{Binding ShowAllContacts, Mode=TwoWay}" 
                     Content="{resx:Resx Filter_ByType_ShowAll}" ToolTip="{Resx Filter_ByType_ShowAll_ToolTip}"
                     />
        /// etc.
    </StackPanel>
</DataTemplate>

used in another stackpanel view

        <StackPanel x:Name="_filterByNameOptions" DockPanel.Dock="Left" Orientation="Horizontal" Margin="5, 5" >
            // ... more stuff

            <ContentPresenter Content="{StaticResource FilterTypeByTemplateControl}"/>

        </StackPanel>

enter image description here

, finally!

It works

<ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource FilterTypeByTemplateControl}"/>

enter image description here

+3
source share
1 answer
<ContentControl 
      ContentTemplate="{StaticResource FilterTypeByTemplateControl}" />
0
source

All Articles