我只是想将StackPanel内容放到ResourceDictionary中。我试着把它包装成数据模板,但没有去。其他一些模板?风格?
如何将其提取到资源,然后在视图的网格布局中使用内容?
干杯,
Berryl
<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>
<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>
<StackPanel x:Name="_filterByNameOptions" DockPanel.Dock="Left" Orientation="Horizontal" Margin="5, 5" >
// ... more stuff
<ContentPresenter Content="{StaticResource FilterTypeByTemplateControl}"/>
</StackPanel>
这有效
<ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource FilterTypeByTemplateControl}"/>
答案 0 :(得分:0)
<ContentControl
ContentTemplate="{StaticResource FilterTypeByTemplateControl}" />