簡體   English   中英

如何使用 DataBinding 處理事件雙擊?

[英]How to handle event Double click using DataBinding?

我有一個項目,當我雙擊ShapeToolUI.xaml按鈕時,我想將ShapeDesigner.xaml的形狀顯示到MainWindow.xaml Grid ,我該怎么做。 非常感謝。 這是 .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>

形狀工具界面.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”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM