如何检查AttachedFlyout是否打开

时间:2016-08-07 06:23:16

标签: c# xaml uwp uwp-xaml

我拥有的是:

person1 = {
    name = "bob" ,
    age = 70 ,
    hair = "black" ,
};
person2 = {
    name = "dan",
    age = 40 ,
    hair = "blonde" , 
};
describe = function(parent)
    parent = _G[parent]
    print ( "hello " .. parent.name .. " your are " .. parent.age .. " years old and your hair color is " .. parent.hair )
end
print ("who are you") ;
answer = io.read ();
describe (answer) 

我可能会遗漏一些东西,因为我很惊讶没有内置属性或检查控件的<Grid x:Name="MyGrid"> <FlyoutBase.AttachedFlyout> <MenuFlyout Placement="Bottom"> <MenuFlyoutItem Text="Item 1" /> <MenuFlyoutItem Text="Item 2" /> <MenuFlyoutItem Text="Item 3" /> </MenuFlyout> </FlyoutBase.AttachedFlyout> </Grid> 是否打开的方式。

是否有类似下面提到的代码的直接方式来实现这一目标?

FlyoutBase.AttachedFlyout

1 个答案:

答案 0 :(得分:2)

不幸的是,IsOpen没有MenuFlyout这样的属性。不要问我为什么!

这有点难看,但你可以这样检查:

bool isMenuOpened;
MenuFlyout.GetAttachedFlyout(MyGrid).Opened += (sender, e) => isMenuOpened = true;
MenuFlyout.GetAttachedFlyout(MyGrid).Closed += (sender, e) => isMenuOpened = false;