Wpf 仅当当前模板是工具提示的后代时,Expander.ISExpane才会被展开
我在应用程序中的多个位置使用了Wpf 仅当当前模板是工具提示的后代时,Expander.ISExpane才会被展开,wpf,xaml,binding,findancestor,Wpf,Xaml,Binding,Findancestor,我在应用程序中的多个位置使用了DataTemplate(StaticResource),如ItemsControl、ContentControl和工具提示中 该模板包含一个扩展器,如果数据模板位于工具提示中,我希望其IsExpanded属性为true 有什么建议吗?这会检查父工具提示,如果没有父工具提示,它将被计算为nothing=false: <Expander Name="expJobContacts" IsExpanded="{Binding IsVisible,
DataTemplate
(StaticResource
),如ItemsControl
、ContentControl
和工具提示中
该模板包含一个扩展器
,如果数据模板
位于工具提示
中,我希望其IsExpanded
属性为true
有什么建议吗?这会检查父工具提示,如果没有父工具提示,它将被计算为nothing=false:
<Expander Name="expJobContacts"
IsExpanded="{Binding IsVisible,
RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType={x:Type ToolTip}},
Mode=OneTime}" />
我测试过了,它能工作