我正在创建一个带有汉堡菜单的UWP应用程序汉堡包菜单;它是一个有一些按钮和图标的堆叠面板;无论如何,主页面从互联网加载项目并向下滚动以查看更多项目,问题是当我在Windows 10移动设备上启动应用程序时,菜单永远不会打开。每次我水平滑动,菜单都不会显示。我尝试在PC上用鼠标滑动菜单显示,但在手机上滑动转换为滚动,所以没有任何反应:/任何想法?
这是我的主页代码:
<StackPanel x:Name="stckpnlMenuTop" Padding="0,40,0,0" HorizontalAlignment="Left" Background="{ThemeResource ComboBoxPopupBorderThemeBrush}" RenderTransformOrigin="0,0" Width="300">
<StackPanel.RenderTransform>
<TranslateTransform x:Name="trnslttrnsfrmMenuTop"/>
</StackPanel.RenderTransform>
<Grid x:Name="top" VerticalAlignment="Top" Margin="0,49,0,0" Height="491">
<Grid x:Name="frontslider" Margin="0,-109,0,519" RenderTransformOrigin="0.5,0.5" Background="{StaticResource BoxBackground}"/>
<Grid x:Name="top_back" HorizontalAlignment="Left" Height="81" Margin="0,-109,0,0" VerticalAlignment="Top" Width="300" PointerEntered="top_back_PointerEntered" PointerExited="top_back_PointerExited" Tapped="top_back_Tapped">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Grid.Background>
<SolidColorBrush Color="#FF3A3A3A" Opacity="0.30000001192092896"/>
</Grid.Background>
</Grid>
<Button x:Name="slider_botton" FontFamily="Segoe MDL2 Assets" Content="" HorizontalAlignment="left" Margin="0,-76,0,0" VerticalAlignment="Top" Width="48" Height="48" Foreground="White" Tapped="slider_btn_Tapped" BorderBrush="{x:Null}" RenderTransformOrigin="0.458,-0.833" Background="{x:Null}"/>
<Grid x:Name="android_back" HorizontalAlignment="Left" Height="48" Margin="0,125,0,0" VerticalAlignment="Top" Width="300" PointerEntered="android_back_PointerEntered" PointerExited="android_back_PointerExited" Tapped="android_tab">
<Grid.Background>
<SolidColorBrush Color="#FF3A3A3A" Opacity="0.30000001192092896"/>
</Grid.Background>
</Grid>
<Grid x:Name="home_back" HorizontalAlignment="Left" Height="57" Margin="0,-28,0,0" VerticalAlignment="Top" Width="300" Tapped="home_tapped" PointerExited="home_back_PointerExited" PointerEntered="home_back_PointerEntered">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Grid.Background>
<SolidColorBrush Color="#FF3A3A3A" Opacity="0.30000001192092896"/>
</Grid.Background>
</Grid>
<Grid x:Name="windows10_back" HorizontalAlignment="Left" Height="48" Margin="0,29,0,0" VerticalAlignment="Top" Width="300" PointerEntered="windows10_back_PointerEntered" PointerExited="windows10_back_PointerExited" Tapped="windows10_tap">
<Grid.Background>
<SolidColorBrush Color="#FF3A3A3A" Opacity="0.30000001192092896"/>
</Grid.Background>
</Grid>
<Grid x:Name="windowspho_back" HorizontalAlignment="Left" Height="48" Margin="0,77,0,0" VerticalAlignment="Top" Width="300" Tapped="winphon_tab" PointerEntered="windowspho_back_PointerEntered" PointerExited="windowspho_back_PointerExited">
<Grid.Background>
<SolidColorBrush Color="#FF3A3A3A" Opacity="0.30000001192092896"/>
</Grid.Background>
</Grid>
<Grid x:Name="nokia_back" HorizontalAlignment="Left" Height="48" Margin="0,173,0,0" VerticalAlignment="Top" Width="300" PointerEntered="nokia_back_PointerEntered" PointerExited="nokia_back_PointerExited" Tapped="nokia_tab">
<Grid.Background>
<SolidColorBrush Color="#FF3A3A3A" Opacity="0.30000001192092896"/>
</Grid.Background>
</Grid>
<Grid x:Name="games_back" HorizontalAlignment="Left" Height="48" Margin="0,221,0,0" VerticalAlignment="Top" Width="300" Tapped="games_tab" PointerExited="games_back_PointerExited" PointerEntered="games_back_PointerEntered">
<Grid.Background>
<SolidColorBrush Color="#FF3A3A3A" Opacity="0.30000001192092896"/>
</Grid.Background>
</Grid>
<TextBlock x:Name="Windows10_text" Foreground="White" HorizontalAlignment="Left" Margin="60,42,0,0" TextWrapping="Wrap" Text="ويندوز 10" VerticalAlignment="Top" PointerEntered="windows10_back_PointerEntered" Tapped="windows10_tap" PointerExited="windows10_back_PointerExited"/>
<TextBlock x:Name="windowspho_text" Foreground="White" HorizontalAlignment="Left" Margin="60,94,0,0" TextWrapping="Wrap" Text="ويندوز 10 موبايل" VerticalAlignment="Top" PointerEntered="windowspho_back_PointerEntered" PointerExited="windowspho_back_PointerExited" Tapped="winphon_tab"/>
<TextBlock x:Name="android_text" Foreground="White" HorizontalAlignment="Left" Margin="60,142,0,0" TextWrapping="Wrap" Text="أندرويد" VerticalAlignment="Top" PointerEntered="android_back_PointerEntered" PointerExited="android_back_PointerExited" Tapped="android_tab"/>
<TextBlock x:Name="nokia_text" Foreground="White" HorizontalAlignment="Left" Margin="60,191,0,0" TextWrapping="Wrap" Text="نوكيا" VerticalAlignment="Top" PointerEntered="nokia_back_PointerEntered" PointerExited="nokia_back_PointerExited" Tapped="nokia_tab"/>
<TextBlock x:Name="home_btn" Foreground="White" FontFamily="Segoe MDL2 Assets" Text="" HorizontalAlignment="Left" Margin="14,-11,0,0" VerticalAlignment="Top" Width="38" Height="24" Tapped="home_tapped" FontSize="20" RenderTransformOrigin="0.52,0.967" PointerEntered="home_back_PointerEntered" PointerExited="home_back_PointerExited"/>
<TextBlock x:Name="home_btn_text" Foreground="White" HorizontalAlignment="Left" Margin="60,-11,0,0" TextWrapping="Wrap" Text="الرئيسية" VerticalAlignment="Top" PointerEntered="home_back_PointerEntered" PointerExited="home_back_PointerExited" Tapped="home_tapped"/>
<TextBlock x:Name="windows10_icon" Foreground="White" FontFamily="Segoe MDL2 Assets" Text="" HorizontalAlignment="Left" Margin="14,43,0,0" VerticalAlignment="Top" Width="38" Height="24" Tapped="windows10_tap" FontSize="20" RenderTransformOrigin="0.52,0.967" PointerEntered="windows10_back_PointerEntered" PointerExited="windows10_back_PointerExited"/>
<TextBlock x:Name="windowspho_icon" Foreground="White" FontFamily="Segoe MDL2 Assets" Text="" HorizontalAlignment="Left" Margin="14,91,0,0" VerticalAlignment="Top" Width="38" Height="24" Tapped="winphon_tab" FontSize="20" RenderTransformOrigin="0.52,0.967" PointerEntered="windowspho_back_PointerEntered" PointerExited="windowspho_back_PointerExited"/>
<TextBlock x:Name="android_icon" Foreground="White" FontFamily="Segoe MDL2 Assets" Text="" HorizontalAlignment="Left" Margin="14,139,0,0" VerticalAlignment="Top" Width="38" Height="24" Tapped="android_tab" FontSize="20" RenderTransformOrigin="0.52,0.967" PointerEntered="android_back_PointerEntered" PointerExited="android_back_PointerExited"/>
<TextBlock x:Name="nokia_icon" Foreground="White" FontFamily="Segoe MDL2 Assets" Text="" HorizontalAlignment="Left" Margin="14,189,0,0" VerticalAlignment="Top" Width="38" Height="24" Tapped="nokia_tab" FontSize="20" RenderTransformOrigin="0.52,0.967" PointerEntered="nokia_back_PointerEntered" PointerExited="nokia_back_PointerExited"/>
<TextBlock x:Name="games_text" Foreground="White" HorizontalAlignment="Left" Margin="60,236,0,0" TextWrapping="Wrap" Text="ألعاب" VerticalAlignment="Top" PointerEntered="games_back_PointerEntered" PointerExited="games_back_PointerExited" Tapped="games_tab"/>
<TextBlock x:Name="games_icon" Foreground="White" FontFamily="Segoe MDL2 Assets" Text="" HorizontalAlignment="Left" Margin="14,234,0,0" VerticalAlignment="Top" Width="38" Height="24" Tapped="games_tab" FontSize="20" RenderTransformOrigin="0.52,0.967" PointerEntered="games_back_PointerEntered" PointerExited="games_back_PointerExited"/>
</Grid>
</StackPanel>
<StackPanel x:Name="stckpnlMenuBottom" HorizontalAlignment="Left" VerticalAlignment="Bottom" Background="{ThemeResource ComboBoxPopupBorderThemeBrush}" RenderTransformOrigin="0,0" Padding="0,0,0,10" Height="238">
<StackPanel.RenderTransform>
<TranslateTransform x:Name="trnslttrnsfrmMenuBottom"/>
</StackPanel.RenderTransform>
<Grid x:Name="bottom" VerticalAlignment="Bottom" Height="232">
<Grid x:Name="contact_back" HorizontalAlignment="Left" Height="48" Margin="0,133,0,0" VerticalAlignment="Top" Width="300" Tapped="contact_tab" PointerEntered="contact_back_PointerEntered" PointerExited="contact_back_PointerExited">
<Grid.Background>
<SolidColorBrush Color="#FF3A3A3A" Opacity="0.30000001192092896"/>
</Grid.Background>
</Grid>
<Grid x:Name="settings_back" HorizontalAlignment="Left" Height="48" Margin="0,181,0,-7" VerticalAlignment="Top" Width="300" PointerEntered="settings_back_PointerEntered" PointerExited="settings_back_PointerExited" Tapped="setting_tab">
<Grid.Background>
<SolidColorBrush Color="#FF3A3A3A" Opacity="0.30000001192092896"/>
</Grid.Background>
</Grid>
<Rectangle x:Name="flowitems" FlowDirection="RightToLeft"
Tapped="contact_tab" Margin="0,133,20,55">
<FlyoutBase.AttachedFlyout>
<MenuFlyout x:Name = "option_menu">
<MenuFlyoutItem x:Name="FeedBack" FlowDirection="RightToLeft" Text="إرسال مشكلة" Width="241" PointerEntered="FeedBack_PointerEntered" Click="FeedBack_Click" >
<MenuFlyoutItem.Template>
<ControlTemplate TargetType="MenuFlyoutItem">
<StackPanel Margin="12,10,0,10" Orientation="Horizontal">
<FontIcon Margin="0,0,12,0" FontFamily="Segoe MDL2 Assets" Glyph="" />
<TextBlock Text="{TemplateBinding Text}" />
</StackPanel>
</ControlTemplate>
</MenuFlyoutItem.Template>
</MenuFlyoutItem>
<MenuFlyoutItem x:Name="StoreRate" FlowDirection="RightToLeft" Text="تقييم التطبيق في المتجر" Width="241" Background="Gray" Click="StoreRate_Click" >
<MenuFlyoutItem.Template>
<ControlTemplate TargetType="MenuFlyoutItem">
<StackPanel Margin="12,10,0,10" Orientation="Horizontal">
<FontIcon Margin="0,0,12,0" FontFamily="Segoe MDL2 Assets" Glyph="" />
<TextBlock Text="{TemplateBinding Text}" />
</StackPanel>
</ControlTemplate>
</MenuFlyoutItem.Template>
</MenuFlyoutItem>
<MenuFlyoutItem x:Name="TextMe" FlowDirection="RightToLeft" Text="مراسلة المصمم" Width="241" Background="Gray" Click="TextMe_Click">
<MenuFlyoutItem.Template>
<ControlTemplate TargetType="MenuFlyoutItem">
<StackPanel Margin="12,10,0,10" Orientation="Horizontal">
<FontIcon Margin="0,0,12,0" FontFamily="Segoe MDL2 Assets" Glyph="" Width="22" />
<TextBlock Text="{TemplateBinding Text}" />
</StackPanel>
</ControlTemplate>
</MenuFlyoutItem.Template>
</MenuFlyoutItem>
</MenuFlyout>
</FlyoutBase.AttachedFlyout>
</Rectangle>
<TextBlock x:Name="contact_text" Foreground="White" HorizontalAlignment="Left" Margin="60,147,0,0" TextWrapping="Wrap" Text="تواصل معنا" VerticalAlignment="Top" PointerEntered="contact_back_PointerEntered" PointerExited="contact_back_PointerExited" Tapped="contact_tab" Height="36" Width="86"/>
<TextBlock x:Name="settings_text" Foreground="White" HorizontalAlignment="Left" Margin="60,194,0,0" TextWrapping="Wrap" Text="الإعدادات" VerticalAlignment="Top" PointerEntered="settings_back_PointerEntered" PointerExited="settings_back_PointerExited" Tapped="setting_tab" Height="27"/>
<TextBlock x:Name="contact_icon" Foreground="White" FontFamily="Segoe MDL2 Assets" Text="" HorizontalAlignment="Left" Margin="14,148,0,0" VerticalAlignment="Top" Width="38" Height="24" Tapped="contact_tab" FontSize="20" RenderTransformOrigin="0.52,0.967" PointerEntered="contact_back_PointerEntered" PointerExited="contact_back_PointerExited"/>
<TextBlock x:Name="settings_icon" Foreground="White" FontFamily="Segoe MDL2 Assets" Text="" HorizontalAlignment="Left" Margin="14,194,0,1" Width="38" Tapped="setting_tab" FontSize="20" RenderTransformOrigin="0.52,0.967" PointerEntered="settings_back_PointerEntered" PointerExited="settings_back_PointerExited"/>
</Grid>
</StackPanel>
我认为这是我在主页上滚动条的问题,但是您应该知道它上面没有滚动查看器,堆栈面板会自动滚动并且没有代码所以我不能禁用水平滚动
答案 0 :(得分:1)
如果您想在UWP中制作汉堡菜单,可以使用SplitView控件进行操作。我不确定如果你知道这种控制,我就像Shubham Sahu所说的那样提到它。如果您对使用SplitView控件制作汉堡包感兴趣,可以阅读此博客Windows 10 SplitView – Build Your First Hamburger Menu了解详细信息。
如果您仍想像上面的xaml代码那样自己动手,但是无法解决当前的问题。请提供完整的可重现代码示例。因为您只是发布了您的xaml代码,但是您已经注册了这么多事件处理程序。你还没有发布任何C#代码,因此,我不知道你在代码隐藏中做了什么。
答案 1 :(得分:0)
之前我使用过splitview,但滑动触摸非常糟糕,所以我使用了这个,我已经解决了我的问题,在左侧添加了一个32px的网格,所以我可以从它上面刷卡谢谢你的帮助和是的,我很抱歉没有发布这些信息!因为我的c#代码很大所以我不能在这里发布希望这会帮助任何人搜索它!