I have a Wpf popup ,which has IsOpen property as
IsOpen="{Binding ElementName=GridItem,Path=IsMouseOver, Mode=OneWay,
UpdateSourceTrigger=PropertyChanged}"
and also StaysOpen= True.
Inside the popup , I have a list box and each listboxitem contains a button as control template. I want to close the popup on clicking on the button but I am not able to close the popup on by clicking the button inside it.
Now if I use StaysOpen=False there are two different issues observed -
While changing from one Grid item to other grid item, popup is not
generated for newly hovered item.
On left button down on Grid item , popup gets hidden.
My code snippet is as follows,
UpdateSourceTrigger=PropertyChanged}" StaysOpen= True>
...
..
Please help me in this regard.
解决方案
Namespace
xmlns:i ="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
Trigger with RelativeSource
TargetObject="{Binding RelativeSource={RelativeSource AncestorType=Popup}}"
PropertyName="StaysOpen" Value="False">
TargetObject="{Binding RelativeSource={RelativeSource AncestorType=Popup}}"
PropertyName="IsOpen" Value="False">