WPF, XAML

WPF 양방향 데이터바인딩 예제

OJC 0 113 10.12 14:22

WPF 양방향 데이터바인딩 예제 

 

<Window x:Class="WpfApplication9.MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="Window1" Height="300" Width="300">

    <Grid>

        <TextBox Height="23" HorizontalAlignment="Left"

            Margin="230,41,0,0" Name="textBox1" VerticalAlignment="Top"

            Width="120" Text="{Binding ElementName=textBox2,

            Path=Text,Mode=TwoWay,

            UpdateSourceTrigger=PropertyChanged}" />

        <TextBox Height="23" HorizontalAlignment="Left"

            Margin="230,98,0,0" Name="textBox2" VerticalAlignment="Top"

            Width="120" />

    </Grid>

</Window>

 

 

<Window x:Class="WpfApplication9.MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="Window1" Height="500" Width="500">

    <Grid>

        <TextBox Height="23" HorizontalAlignment="Left"

            Margin="230,41,0,0" Name="textBox1" VerticalAlignment="Top"

            Width="120" Text="{Binding ElementName=textBox2,

            Path=Text,Mode=TwoWay}" />

        <TextBox Height="23" HorizontalAlignment="Left"

            Margin="230,98,0,0" Name="textBox2" VerticalAlignment="Top"

            Width="120" 

            Text="{Binding ElementName=textBox1,

            Path=Text,Mode=TwoWay}"/>

    </Grid>

</Window>


Comments