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”。为什么有一个没有命令或事件处理程序的按钮?按钮被设计成当你点击时做一些事情。