如何在 WPF 中设置扩展器控件的最小大小?
如何设置扩展器以显示它包含的某些内容,即使在折叠状态下也是如此? 我有以下代码片段,任何人都可以指出对此代码的更改吗?
<Window x:Class="UI2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="358" Width="300">
<TabControl>
<TabItem Header="Buga Buga">
<StackPanel>
<Expander ClipToBounds="False">
<ListBox Name="lstProcesses"
MinHeight="60">
</ListBox>
</Expander>
</StackPanel>
</TabItem>
</TabControl>
谢谢
How can I set expander to show some content it encloses even in collapsed state ? I have the following code snippet, can anyone point changes to this code ?
<Window x:Class="UI2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="358" Width="300">
<TabControl>
<TabItem Header="Buga Buga">
<StackPanel>
<Expander ClipToBounds="False">
<ListBox Name="lstProcesses"
MinHeight="60">
</ListBox>
</Expander>
</StackPanel>
</TabItem>
</TabControl>
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来 Expander 不是您应该在这种情况下使用的控件。 Expander 有一个标题和内容,如下所示:
在我看来,您想要一个有时设置为特定高度而有时不受限制的控件。
我认为您可以通过将
ToggleButton
(Expander 在内部也使用)绑定到ListBox
的MaxHeight
属性来实现此目的。在 Kaxaml 中尝试类似的操作:
It doesn't sound like Expander is the control you should be using for this scenario. Expander has a header, and content, like this:
It sounds to me like you want a control that's set to a specific height some of the time, and unrestrained at other times.
I think you could achieve this by binding a
ToggleButton
(which Expander uses too, internally) to theMaxHeight
property of yourListBox
.Try something like this in Kaxaml:
以下是如何将折叠文本(标题)添加到扩展器中包含的列表框中所选项目的快速示例:
Here's a quick example of how to the Collapsed text (the Header) to the selected item in the listbox contained within the expander: