简体   繁体   English

在XAML中重用StackPanel UI

[英]Reuse StackPanel UI in XAML

I have multiple StackPanels in my UI. 我的UI中有多个StackPanels。

<StackPanel>
          <Button>Button 1</Button>
</StackPanel>
<StackPanel>
          <TextBlock Style= Margin="3,0,0,0" x:Name="Name" ../>
</StackPanel>
<StackPanel>
          <TextBox Margin="3,0,0,0" x:Name="Number" Width="35".. />
</StackPanel>

I want to use the button and textblock in one dialog and textblock and textbox in other. 我想在一个对话框中使用按钮和文本块,在另一个对话框中使用文本块和文本框。 How do I do that? 我怎么做?

Create a custom control using the stackpanels with specific dependency properties which allow for the transfer of meta data (such as titles and other items) and actual data from the user to flow back and forth. 使用具有特定依赖项属性的堆栈面板创建自定义控件,以允许元数据(例如标题和其他项目)和实际数据从用户的来回传输。 Within it, utilize a content presenter Content Presenter to allow for unique content depending on the situation. 在其中,利用内容呈现器Content Presenter根据情况允许唯一的内容。

See How To Create A Custom Control to get started. 请参阅如何开始创建自定义控件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM