【发布时间】:2020-10-10 03:12:40
【问题描述】:
我有一个项目,当我双击ShapeToolUI.xaml 按钮时,我想在MainWindow.xaml 中显示ShapeDesigner.xaml 到Grid 的形状,我该怎么做。太感谢了。
这是 .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