English 中文(简体)
如何使用这个堆叠板作为资源
原标题:How to Use This StackPanel as a Resource

我只是想把StackPannel 内容输入资源词典中。 我尝试把它包成数据临时模板,但没有去。 另一种模板? 风格?

我怎样才能将它提取到资源中 然后使用我所看到的网格布局的内容?

Cheers,
Berryl

the 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 of the view

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

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

        </StackPanel>

""https://i.sstatic.net/8g1xP.jpg" alt="此处输入图像描述"/ >

finally!

这个作品

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

""https://i.sstatic.net/fSK4g.jpg" alt="此处输入图像描述"/ >

最佳回答
<ContentControl 
      ContentTemplate="{StaticResource FilterTypeByTemplateControl}" />
问题回答

暂无回答




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签