Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Copy Textbox Value To Another When Click On Button Command In WPF MVVM

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 843
    Answer it

    Here my xaml file :

     

    <TextBox Height="30" Width="100" Text="{Binding Path=txtName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="346,239,346,150"/>

     

            <Button Name="Submit" Height="30" Width="100" Content="Submit Me" Command="{Binding submit}" CommandParameter="{Binding Text, ElementName=fName}" Margin="346,185,346,204"/>

     

            <TextBox Height="30" Width="100" Text="{Binding Path=copyName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="346,135,346,254" />

     

    This is my ViewModel.cs

     

    public event PropertyChangedEventHandler PropertyChanged;

            private string _txtName;

            public string txtName
            {
                get { return _txtName; }
                set {
                    _txtName = value;
                    OnPropertyChanged("txtName");
                    }
                
            }
            private int _copyName;

            public int copyName
            {
                get { return _copyName; }
                set { _copyName = value;
                    OnPropertyChanged("copyName");
                    }
            }

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: