StackPanel のコンテンツを ResourceDictionary に取得しようとしています。データテンプレートにラップしようとしましたが、うまくいきませんでした。他の種類のテンプレートですか?スタイル?
これをリソースに抽出し、ビューのグリッド レイアウトでコンテンツを使用するにはどうすればよいですか?
乾杯、
ベリル
移動するxaml
<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 で使用される
<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}"/>