日月同辉山川同在 2021-10-31 19:10 采纳率: 33.3%
浏览 14
已结题

关于#wpf#的问题:MenuItem 的CommandParameter怎么绑定Window对象

<Window x:Class="ModernBoxes.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:ModernBoxes"
        mc:Ignorable="d"
        WindowStartupLocation="CenterScreen"
        ResizeMode="NoResize"
        MouseLeftButtonDown="Grid_MouseLeftButtonDown"
        Background="Transparent"
        
        xmlns:hc="https://handyorg.github.io/handycontrol"
        
        x:Name="window"
        Title="MainWindow" Height="800" Width="800">
    <hc:Card hc:BorderElement.CornerRadius="20"  Background="White" Effect="{StaticResource EffectShadow1}">
        <hc:Card.ContextMenu>
            <ContextMenu>
                <MenuItem Header="展开"/>
                <MenuItem Header="收缩"/>
                <MenuItem Header="关闭" Command="{Binding WindowClose}" 
                          CommandParameter="{
                    Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ContextMenu}
                    ,Path=PlacementTarget}"/>
            </ContextMenu>
        </hc:Card.ContextMenu>

    </hc:Card>
</Window>

MenuItem 的CommandParameter怎么绑定Window对象

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 11月8日
    • 创建了问题 10月31日

    悬赏问题

    • ¥15 安霸cv22 + rtl8211f 千兆,udp传输丢包
    • ¥15 关于区块链和边缘环境搭建的相关问题
    • ¥15 windows远程桌面断卡重连软件卡顿问题
    • ¥30 Unity 实现扫描效果
    • ¥15 HbuilderX检测不到安卓模拟器
    • ¥15 这个main已经在filename.obj中定义是什么错 C语言
    • ¥15 关于#linux#的问题:exsi8.0系统 怎么更改web访问端口,不用80、443
    • ¥15 使用elementor设计样式
    • ¥15 谁能提供一个中文版的推销咨询网站连接?
    • ¥15 springboot项目程序启动报错