Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用数据绑定处理事件双击?_C#_Wpf_Xaml_Data Binding - Fatal编程技术网

C# 如何使用数据绑定处理事件双击?

C# 如何使用数据绑定处理事件双击?,c#,wpf,xaml,data-binding,C#,Wpf,Xaml,Data Binding,我有一个项目,我想在ShapeDesigner.xaml中显示一个形状到main window.xaml中的Grid当我双击shapetouli.xaml按钮时,我该怎么做呢。非常感谢你。 这是.xaml代码 ShapeDesigner.xaml <Canvas x:Name="Canvas"> <!-- Draw circle--> <ContentControl x:Name="Circle"

我有一个项目,我想在
ShapeDesigner.xaml
中显示一个形状到
main window.xaml中的
Grid
当我双击
shapetouli.xaml
按钮时,我该怎么做呢。非常感谢你。 这是.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>
<Grid Background="#FFBCE6FF" >
    // I want to display Canvas in ShapeDesigner in here when double-clicked button in ShapeToolUI
</Grid>
<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>


main window.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>
<Grid Background="#FFBCE6FF" >
    // I want to display Canvas in ShapeDesigner in here when double-clicked button in ShapeToolUI
</Grid>
<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>


//我想在这里双击ShapeTooli中的按钮时在ShapeDesigner中显示画布
shapetouli.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>
<Grid Background="#FFBCE6FF" >
    // I want to display Canvas in ShapeDesigner in here when double-clicked button in ShapeToolUI
</Grid>
<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>


非常感谢您的“显示菱形”定义在哪里?
如果没有,则需要首先定义。并从该函数内部调用“Circle”。

为什么有一个没有命令或事件处理程序的按钮?按钮被设计成当你点击时做一些事情。