c# - 它的选中状态是怎么去掉的?

标签 c# xaml uwp template10

那条白线 that white line

我想将它分开,但有问题。如何将堆栈面板放在 Hamburger 菜单 top.F stackpanel中的HamburgerButtonInfo,每次点击,整个HamburgerButtonInfo都被选中,如何去掉整体选中的效果?

<Page
    x:Class="心理FM.Views.Shell"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:Controls="using:Template10.Controls"
      xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
      xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
      xmlns:behaviors="using:Template10.Behaviors"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="using:心理FM.Views"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:views="using:心理FM.Views"
      Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
      mc:Ignorable="d">
    <Controls:HamburgerMenu x:Name="MyHamburgerMenu"
                            >
        <Controls:HamburgerMenu.PrimaryButtons>
            <!--头像,签到-->
            <Controls:HamburgerButtonInfo >
                <StackPanel Orientation="Horizontal" Width="400" Height="150">
                    <StackPanel.Background>
                        <ImageBrush ImageSource="../Assets/04.jpg"></ImageBrush>
                    </StackPanel.Background>
                    <Ellipse Height="70" Width="70" Margin="10,60,0,10">
                        <Ellipse.Fill>
                                <ImageBrush ImageSource="../Assets/IMG_0003.JPG" />
                        </Ellipse.Fill>
                    </Ellipse>
                    <StackPanel VerticalAlignment="Center" Margin="10,45,0,0">
                        <TextBlock Name="UserName" Text="user" FontSize="20" VerticalAlignment="Center"/>
                        <TextBlock Name="Count" Text="null" FontSize="20" VerticalAlignment="Center"/>
                    </StackPanel>
                    <Button Name="SignBtn" Content="签到" HorizontalAlignment=""  VerticalAlignment="Bottom"></Button>

                </StackPanel>
            </Controls:HamburgerButtonInfo>
            <Controls:HamburgerButtonInfo ClearHistory="True">
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                    <Image Source="../Assets/"></Image>
                    <TextBlock Text="我关注的" Margin="12, 0, 0, 0" VerticalAlignment="Center" />
                </StackPanel>
            </Controls:HamburgerButtonInfo>
            <Controls:HamburgerButtonInfo ClearHistory="True">
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                    <Image Source="../Assets/"></Image>
                    <TextBlock Text="我的下载" Margin="12, 0, 0, 0" VerticalAlignment="Center" />
                </StackPanel>
            </Controls:HamburgerButtonInfo>
            <Controls:HamburgerButtonInfo ClearHistory="True">
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                    <Image Source="../Assets/"></Image>
                    <TextBlock Text="我的话题" Margin="12, 0, 0, 0" VerticalAlignment="Center" />
                </StackPanel>
            </Controls:HamburgerButtonInfo>
            <Controls:HamburgerButtonInfo ClearHistory="True">
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                    <Image Source="../Assets/"></Image>
                    <TextBlock Text="定时关闭" Margin="12, 0, 0, 0" VerticalAlignment="Center" />
                </StackPanel>
            </Controls:HamburgerButtonInfo>
            <Controls:HamburgerButtonInfo ClearHistory="True">
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                    <Image Source="../Assets/"></Image>
                    <TextBlock Text="通知"  Margin="12, 0, 0, 0" VerticalAlignment="Center" />
                </StackPanel>
            </Controls:HamburgerButtonInfo>
            <Controls:HamburgerButtonInfo ClearHistory="True">
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                    <Image Source="../Assets/"></Image>
                    <TextBlock Text="私信" Margin="12, 0, 0, 0" VerticalAlignment="Center" />
                </StackPanel>
            </Controls:HamburgerButtonInfo>
        </Controls:HamburgerMenu.PrimaryButtons>

        <Controls:HamburgerMenu.SecondaryButtons>
            <!--  profile button  -->
            <Controls:HamburgerButtonInfo ButtonType="Command">
                <Interactivity:Interaction.Behaviors>
                    <Core:EventTriggerBehavior EventName="Tapped">
                        <behaviors:MessageDialogAction Title="Show profile" Content="This is an example of a Command-type hamburger button. It does not navigate, only raises the Tapped event for some custom implementation." />
                    </Core:EventTriggerBehavior>
                </Interactivity:Interaction.Behaviors>
                <StackPanel Orientation="Horizontal">
                    <ToolTipService.ToolTip>
                        <TextBlock MaxWidth="225"
                                   Text="This is the tooltip for the Show Profile command button. Remember to localize."
                                   TextWrapping="Wrap" />
                    </ToolTipService.ToolTip>
                    <SymbolIcon Width="48"
                                Height="48"
                                Symbol="Contact" />
                    <TextBlock Margin="12,0,0,0"
                               VerticalAlignment="Center"
                               Text="User profile" />
                </StackPanel>
            </Controls:HamburgerButtonInfo>
            <!--  settingspage button  -->
            <Controls:HamburgerButtonInfo x:Name="SettingsButton"
                                          PageParameter="0"
                                          PageType="views:SettingsPage">
                <Controls:HamburgerButtonInfo.NavigationTransitionInfo>
                    <SuppressNavigationTransitionInfo />
                </Controls:HamburgerButtonInfo.NavigationTransitionInfo>
                <StackPanel Orientation="Horizontal">
                    <SymbolIcon Width="48"
                                Height="48"
                                Symbol="Setting" />
                    <TextBlock Margin="12,0,0,0"
                               VerticalAlignment="Center"
                               Text="Settings" />
                </StackPanel>
            </Controls:HamburgerButtonInfo>
        </Controls:HamburgerMenu.SecondaryButtons>

    </Controls:HamburgerMenu>
</Page>

最佳答案

您只需在第一个 Controls:HamburgerButtonInfo 中将 ButtonType 设置为 Literal

HamburgerButton 共有三种类型:Command、Toggle 和 Literal,默认为“Toggle”,您可以更改此属性以查看不同之处。

简而言之,在这种情况下,您可以这样修改代码:

<Controls:HamburgerButtonInfo ButtonType="Literal">
    <StackPanel Orientation="Horizontal" Width="400" Height="150">
        <StackPanel.Background>
            <ImageBrush ImageSource="../Assets/04.jpg"></ImageBrush>
        </StackPanel.Background>
        <Ellipse Height="70" Width="70" Margin="10,60,0,10">
            <Ellipse.Fill>
                <ImageBrush ImageSource="../Assets/IMG_0003.JPG" />
            </Ellipse.Fill>
        </Ellipse>
        <StackPanel VerticalAlignment="Center" Margin="10,45,0,0">
            <TextBlock Name="UserName" Text="user" FontSize="20" VerticalAlignment="Center"/>
            <TextBlock Name="Count" Text="null" FontSize="20" VerticalAlignment="Center"/>
        </StackPanel>
        <Button Name="SignBtn" Content="签到" HorizontalAlignment=""  VerticalAlignment="Bottom"></Button>

    </StackPanel>
</Controls:HamburgerButtonInfo>

关于c# - 它的选中状态是怎么去掉的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40243289/

相关文章:

c# - UWP 后台任务错误

c# - 使用 C# 打开 powerpoint 文档时调用 COM 组件返回错误 HRESULT E_FAIL

c# - WPF 中的条件样式

c# - 如何在WPF中的图像上制作透明 Canvas ?

c# - 无法在跨 Windows 10 版本的 NavigationView 项目模板中实现相同的行为

c# - 监听业务逻辑的 PropertyChanged 事件

c# - 哪种技术更适合成为移动开发人员 C# 或 java?

c# - 循环静态只读字段定义的奇怪行为

c# - 以 string.contains() 作为参数的 switch() 语句

c# - 当前不可见时展开/选择 TreeView 节点