简体   繁体   English

如何忽略按钮以捕获我们在Template10中忽略的按钮内的按钮单击?

[英]How to ignore button to capture click of buttons inside the button that we ignore in Template10?

I want to click a combobox inside a template10 HamburgerMenu literal button. 我想单击template10 HamburgerMenu文字按钮内的组合框。 How do I do that. 我怎么做。

<Controls:HamburgerMenu x:Name="MyHamburgerMenu" PaneWidth="272">

    <Controls:HamburgerMenu.PrimaryButtons>
        <!--  user potrait  -->
        <Controls:HamburgerButtonInfo ButtonType="Literal" ClearHistory="True">
            <RelativePanel Margin="52,4,12,4">
                <Ellipse
                    x:Name="Potrait"
                    Width="100"
                    Height="100"
                    Margin="4"
                    RelativePanel.AlignLeftWithPanel="True"
                    RelativePanel.AlignRightWithPanel="True"
                    RelativePanel.AlignTopWithPanel="True"
                    Stroke="Black">
                    <Ellipse.Fill>
                        <ImageBrush ImageSource="ms-appx:///Assets/child potrait.jpg" Stretch="UniformToFill" />
                    </Ellipse.Fill>
                </Ellipse>
                <ComboBox
                    x:Name="User"
                    Margin="4"
                    HorizontalAlignment="Stretch"
                    RelativePanel.AlignLeftWithPanel="True"
                    RelativePanel.AlignRightWithPanel="True"
                    RelativePanel.Below="Potrait">
                    <ComboBoxItem Content="Amir" IsSelected="True" />
                    <ComboBoxItem Content="Aishah" />
                    <ComboBoxItem Content="Alia" />
                </ComboBox>
                <ComboBox
                    Margin="4"
                    HorizontalAlignment="Stretch"
                    RelativePanel.AlignLeftWithPanel="True"
                    RelativePanel.AlignRightWithPanel="True"
                    RelativePanel.Below="User">
                    <ComboBoxItem Content="Matematik" IsSelected="True" />
                    <ComboBoxItem Content="Bahasa Malaysia" />
                    <ComboBoxItem Content="Bahasa Inggeris" />
                </ComboBox>
            </RelativePanel>
        </Controls:HamburgerButtonInfo>

http://i.imgur.com/HZoLC1P.png http://i.imgur.com/HZoLC1P.png 在此处输入图片说明

I want to click the combobox under the potrait. 我想单击potrait下的组合框。 Right now, when i click anywhere near the potrait(including the combobox), hamburger pane collapse. 现在,当我单击Potrait(包括组合框)附近的任意位置时,汉堡窗格会折叠。

Thanks. 谢谢。

when i click anywhere near the potrait(including the combobox), hamburger pane collapse. 当我单击Potrait(包括组合框)附近的任意位置时,汉堡窗格会折叠。

The "issue" of describing above is HamburgerMenu's feature in Template 10. The following code simply explains this feature. 上面描述的“问题”是Template 10中HamburgerMenu的功能。 下面的代码简单地解释了此功能。

var escape = new Func<bool>(() =>
{
  if (DisplayMode == SplitViewDisplayMode.CompactOverlay
      || DisplayMode == SplitViewDisplayMode.Overlay)
        IsOpen = false;
    if (Equals(ShellSplitView.PanePlacement, SplitViewPanePlacement.Left))
     {
          ShellSplitView.Content.RenderTransform = new TranslateTransform { X = 48 + ShellSplitView.OpenPaneLength };
           focus(FocusNavigationDirection.Right);
           ShellSplitView.Content.RenderTransform = null;
         }
             else
        {
           ShellSplitView.Content.RenderTransform = new TranslateTransform { X = -48 - ShellSplitView.OpenPaneLength };
           focus(FocusNavigationDirection.Left);
           ShellSplitView.Content.RenderTransform = null;
       }
     return true;
});

The escape function will be executed when you touch hamburg content for collapsing hamburger pane. 当您触摸汉堡内容以折叠汉堡窗格时,将执行退出功能。

I have tried to handle your issue directly by setting IsOpen as true when your commbobox PointerEntered just like the following code. 我曾尝试直接通过设定处理您的问题IsOpentrue时,你commbobox PointerEntered就像下面的代码。

private bool canCloseHamburgerMenu = true;
private void User_PointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
    canCloseHamburgerMenu = false;
}

private void User_PointerExited(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
{
    canCloseHamburgerMenu = true;
}

private void MyHamburgerMenu_IsOpenChanged(object sender, ChangedEventArgs<bool> e)
{
    var hm = sender as HamburgerMenu;
    if ((hm.DisplayMode == SplitViewDisplayMode.CompactOverlay || hm.DisplayMode == SplitViewDisplayMode.Overlay) && e.NewValue == false)
    {
        //hm.IsOpen = canCloseHamburgerMenu == false ? true : false;
    }
}

But it throws stack over flow exception. 但是,它将堆栈抛出流异常。 I found the reason in the source code . 我在源代码中找到了原因。

partial void InternalIsOpenChanged(ChangedEventArgs<bool> e)
{
    UpdateIsPaneOpen(e.NewValue);
    UpdateHamburgerButtonGridWidthToFillAnyGap();
    UpdateControl();
}

When I changed IsOpen property the InternalIsOpenChanged method will be executed and reset IsOpen to false and then MyHamburgerMenu_IsOpenChanged event will be activated. 当我更改IsOpen属性时,将执行InternalIsOpenChanged方法并将IsOpen重置为false ,然后将激活MyHamburgerMenu_IsOpenChanged事件。 So the thread goes into an infinite loop. 因此线程进入无限循环。

The class of HamburgerMenu is sealed. HamburgerMenu的类是密封的。 So you could not inherit and rewrite it's method. 因此,您无法继承和重写它的方法。 You could custom new hamburgerMenu by using SplitView . 您可以使用SplitView定制新的hamburgerMenu。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM