Xaml 中的 WPF 扩展器?
我想创建一个 ItemsControl
来提供一些自己的子项,然后在使用时可以添加其他子项,类似于内置的 Expander
类。
但是,在此示例中,Header
TextBlock
也被删除。这是一个改写 我昨天问的一个问题。
LayerPanelItem.xaml:
<ItemsControl x:Class="Controls.LayerPanelItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<TextBlock>Header</TextBlock>
<StackPanel Name="InnerContent">
<!-- Test 1 and Test 2 should go here. -->
</StackPanel>
</StackPanel>
</ItemsControl>
Main.xaml:
<controls:LayerPanelItem>
<TextBlock>Test 1</TextBlock>
<TextBlock>Test 2</TextBlock>
</controls:LayerPanelItem>
I want to make an ItemsControl
that provides some of its own children, and then when used can add additional children, similarly to the built in Expander
class.
However, in this example, the Header
TextBlock
is also removed. This is a rephrasing of
a question I asked yesterday.
LayerPanelItem.xaml:
<ItemsControl x:Class="Controls.LayerPanelItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<TextBlock>Header</TextBlock>
<StackPanel Name="InnerContent">
<!-- Test 1 and Test 2 should go here. -->
</StackPanel>
</StackPanel>
</ItemsControl>
Main.xaml:
<controls:LayerPanelItem>
<TextBlock>Test 1</TextBlock>
<TextBlock>Test 2</TextBlock>
</controls:LayerPanelItem>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,您需要更多
HeaderedItemsControl
。Expander
派生自HeaderedContentControl
,并添加了ItemsControl
行为:If I'm understanding you correctly, you want more of a
HeaderedItemsControl
.Expander
derives fromHeaderedContentControl
and this adds in theItemsControl
behavior to that: