C# 能够选择扩展器上的任意位置进行扩展
我在WPF C#工作,注意到当我单击扩展器的按钮或标题(单词)时,扩展器会膨胀和折叠,但当我单击标题旁边的扩展器部分时,扩展器不会膨胀 奇怪的是,当点击扩展器旁边的同一点时,它会折叠扩展器 那么,有人知道如何允许点击整个扩展器来展开和折叠它吗 非常感谢您的帮助C# 能够选择扩展器上的任意位置进行扩展,c#,wpf,expander,C#,Wpf,Expander,我在WPF C#工作,注意到当我单击扩展器的按钮或标题(单词)时,扩展器会膨胀和折叠,但当我单击标题旁边的扩展器部分时,扩展器不会膨胀 奇怪的是,当点击扩展器旁边的同一点时,它会折叠扩展器 那么,有人知道如何允许点击整个扩展器来展开和折叠它吗 非常感谢您的帮助 <Expander ExpandDirection="Down" Width="Auto" Padding="4" Expanded="Expander_Expanded"> <Expander.Style>
<Expander ExpandDirection="Down" Width="Auto" Padding="4" Expanded="Expander_Expanded">
<Expander.Style>
<Style TargetType="Expander">
<!--<Setter Property="IsExpanded" Value="{Binding XPath=@Name, Converter={StaticResource ExpandConverter}}" />-->
<Setter Property="IsExpanded" Value="{Binding XPath=@Expand}" />
<Setter Property="Header">
<Setter.Value>
<MultiBinding Converter="{StaticResource NameConverter}">
<Binding XPath="@Name" />
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="FontWeight" Value="Bold" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsExpanded,RelativeSource={RelativeSource Self}}" Value="True">
</DataTrigger>
</Style.Triggers>
</Style>
</Expander.Style>
<ListBox Name="itemsList"
ItemsSource="{Binding XPath=UpgradeAction}"
ItemTemplate="{StaticResource dtListItemTemplate}"
SelectionChanged="listItems_SelectionChanged"
Style="{StaticResource styleListBoxUpgradeAction}"
ItemContainerStyle="{StaticResource styleListBoxItemUpgradeAction}"
MouseDoubleClick="itemsList_MouseDoubleClick">
</ListBox>
</Expander>
也许可以看看控制模板?您还可以使用单击事件,查看鼠标是否位于标题部分,并使其成为可重用的行为问题是没有设置扩展器的宽度,因此它是自动的。因此,它在关闭时工作,因为打开时,宽度设置为整个扩展器。但是,它在折叠时不起作用,因为折叠时,扩展器宽度仅设置为与页眉的距离相等。因此,我将宽度更改为一个固定值,它允许我按下扩展器顶部的任何位置来打开和关闭扩展器