4

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}"/>

ここに画像の説明を入力

4

1 に答える 1

0
<ContentControl 
      ContentTemplate="{StaticResource FilterTypeByTemplateControl}" />
于 2012-05-23T19:16:44.430 に答える