c# - 如何使用 DataBinding 处理事件双击?
问题描述
我有一个项目,我想在双击按钮时显示一个形状ShapeDesigner.xaml
,我该怎么做。太感谢了。这是 .xaml 代码Grid
MainWindow.xaml
ShapeToolUI.xaml
形状设计器.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>
主窗口.xaml
<Grid Background="#FFBCE6FF" >
// I want to display Canvas in ShapeDesigner in here when double-clicked button in ShapeToolUI
</Grid>
形状工具UI.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>
非常感谢<3
解决方案
您的“DisplayRhombus”在哪里定义?如果不是,则需要先定义。并从该函数内部调用“Circle”。
推荐阅读
- c# - 具有默认值的枚举扩展方法的通用字符串
- .net-core - EF Power Tools 默认为 pascalcase
- javascript - 如何将这两个数组放在单独的对象中并推送到 JS 中的主数组?
- batch-file - 批处理脚本 - 重写输出
- python - 如何在熊猫中使用 country_converter 将国家代码转换为名称?
- r - 具有 K 个集群和行名注释的热图
- google-chrome - SameSite=none 和不安全的 http cookie 无法在 Chrome 上运行
- javascript - 仅修改 POST XMLHttpRequest 的 headers
- c - 多个 scanf() 用于获取字符串和整数。其中一些被忽视
- python - 使用 Python 和 Selenium 控制 Web 浏览器“消息:没有这样的元素:无法找到元素”(python)