【问题标题】:How to handle event Double click using DataBinding?如何使用 DataBinding 处理事件双击?
【发布时间】:2020-10-10 03:12:40
【问题描述】:

我有一个项目,当我双击ShapeToolUI.xaml 按钮时,我想在MainWindow.xaml 中显示ShapeDesigner.xamlGrid 的形状,我该怎么做。太感谢了。 这是 .xaml 代码

ShapeDesigner.xaml

<Canvas x:Name="Canvas">
    <!-- Draw circle-->
    <ContentControl x:Name="Circle"
        Width="366" Height="312" Canvas.Top="50" Canvas.Left="50"
        MinWidth="50" MaxWidth="200" MinHeight="50" MaxHeight="200"
                Template="{StaticResource DesignShape}" RenderTransformOrigin="3.005,2.555">
        <Ellipse Fill="Red"
                 IsHitTestVisible="False"></Ellipse>
        
    </ContentControl>
</Canvas>

MainWindow.xaml

<Grid Background="#FFBCE6FF" >
    // I want to display Canvas in ShapeDesigner in here when double-clicked button in ShapeToolUI
</Grid>

ShapeToolUI.xaml

<Grid Background="White">
    <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible" >
        <StackPanel Background="#FFBCE6FF">
            <Button  MouseDoubleClick="DisplayRhombus"
                Margin="10,40,10,0" Height="91" Width="100" BorderBrush="#FFBCE6FF" Foreground="#FFBCE6FF">
                <Button.Background>
                    <ImageBrush ImageSource="rhombus.png"/>
                </Button.Background>
            </Button>
</Grid>

非常感谢

【问题讨论】:

  • 为什么有一个没有命令或事件处理程序的按钮?按钮的设计目的是在您单击它们时执行某些操作。

标签: c# wpf xaml data-binding


【解决方案1】:

您的“DisplayRhombus”在哪里定义? 如果不是,则需要先定义。并从该函数内部调用“Circle”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-11
    • 1970-01-01
    • 1970-01-01
    • 2014-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多