I
I
idShura2018-06-05 12:38:33
WPF
idShura, 2018-06-05 12:38:33

How to implement Binding in UserControl?

5b165959c3391639436840.png
I created a UserControl, now I can use it in MainWindow.xaml:

<local:UserControl1 Margin="731,757,10,232" Height="40" />

Tell me how to transfer when using UserControl1 in MainWindow.xaml?:
1. Text in TextBlock
2. Event MouseLeftButtonDown = "MouseLeftButtonDown"
usercontrol
<UserControl x:Class="Boots.UserControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Boots"
             mc:Ignorable="d" >


    <local:MyGrid x:Name="Objx" HorizontalAlignment="Left" VerticalAlignment="Top" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="80" />
            <ColumnDefinition Width="40" />
            <ColumnDefinition Width="40" />

            <ColumnDefinition Width="200" />
            <ColumnDefinition Width="40" />
            <ColumnDefinition Width="40" />
         </Grid.ColumnDefinitions>

        <TextBlock  Grid.Column="0" Grid.Row="0" Margin="1" Text="" HorizontalAlignment="Center" VerticalAlignment="Center"  />

        <local:Cell Grid.Column="1" Grid.Row="0" Content="" />
        <local:Cell Grid.Column="2" Grid.Row="0" Content="" />

        <TextBox Grid.Column="3" Grid.Row="0" Margin="10"/>

        <local:Cell Grid.Column="4" Grid.Row="0" Content=""  />
        <local:Cell Grid.Column="5" Grid.Row="0" Content=""  />

    </local:MyGrid>
</UserControl>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2018-06-05
@idShura

https://metanit.com/sharp/wpf/11.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question