- public class FullName : INotifyPropertyChanged
- {
- private string _ConcatFullName;
- public string ConcatFullName
- {
- get { return _ConcatFullName; }
- set
- {
- if(_ConcatFullName != value)
- {
- _ConcatFullName = value;
- INotifyPropertyChanged("ConcatFullName");
- }
- }
- }
File XAML.cs
//Here I implement a method to show on the UI the concat of two strings in a label
- public MainWindow()
- {
- InitializeComponent();
- this.DataContext = txtFirstName;
- this.DataContext = txtLastName;
- lblConcatTheFullName.DataContext = FullName();
- }
- private string FullName()
- {
- return this.txtFirstName + " " + this.txtLastName;
- }
Unfortunately I don't get the desired result. What is wrong with the data Binding?
Is there any other confortable way to solve this problem?
Any help please?
Many thanks in advance.
Best regards
Johannes