我只是想获得的StackPanel内容转换为ResourceDictionary中。我试着包成一个数据tempplate,但没有去。一些其他种类的模板?样式?
我如何提取这一个资源,然后用在我看来的网格布局的内容?
干杯, Berryl
< StackPanel的X:名称=_ filterByTypeOptions方向=横向保证金=5,5>
<单选按钮样式={的StaticResource FilterPanelRadioButtonStyle}
=器isChecked{结合ShowAllContacts,模式=双向}
内容={RESX:的Resx Filter_ByType_ShowAll}工具提示={的Resx Filter_ByType_ShowAll_ToolTip}
/>
// ...更多相同
< / StackPanel的>
< DataTemplate中X:关键=FilterTypeByTemplateControl>
< StackPanel的X:名称=_ filterByTypeOptions方向=横向保证金=5,5>
<单选按钮样式={的StaticResource FilterPanelRadioButtonStyle}
=器isChecked{结合ShowAllContacts,模式=双向}
内容={RESX:的Resx Filter_ByType_ShowAll}工具提示={的Resx Filter_ByType_ShowAll_ToolTip}
/>
/// 等等。
< / StackPanel的>
< / DataTemplate中>
< StackPanel的X:名称=_ filterByNameOptionsDockPanel.Dock =左倾角度=水平保证金=5,5>
// ...更多的东西
<内容presenter CONTENT ={的StaticResource FilterTypeByTemplateControl}/>
< / StackPanel的>
本作品
<内容presenter CONTENT ={结合}的ContentTemplate ={的StaticResource FilterTypeByTemplateControl}/>
解决方案
< ContentControl中
的ContentTemplate ={的StaticResource FilterTypeByTemplateControl}/>
I am just trying to get the StackPanel content into a ResourceDictionary. I tried wrapping it into a data tempplate but no go. Some other sort of template? A style?
How can I extract this to a resource and then use the content in my view's grid layout?
Cheers, 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>
This works
<ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource FilterTypeByTemplateControl}"/>
解决方案 <ContentControl
ContentTemplate="{StaticResource FilterTypeByTemplateControl}" />