There is a UserControl, it contains several textboxes for changing class fields. So, it’s impossible to bind these class fields in two-way mode to the UserControl text boxes.
View:
<UserControl x:Class="Editor3.Modules.Views.CreateView" xmlns:ViewModels="clr-namespace:Editor3.Modules.ViewModels"> <Grid> <TextBox Text="{Binding Name, Mode=TwoWay}"/> <TextBox Text="{Binding Description}" /> <Button Content="Create" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.CreateCommand}"/> </Grid> ViewModel:
namespace Editor3.Modules.ViewModels { public class CreateViewModel : ViewModelBase, INotifyPropertyChanged { public CreateViewModel() { CreateCommand = new Command(Create); } public Command CreateCommand { get; private set; } World World { get { return GetValue<World>(WorldProperty); } set { SetValue(WorldProperty, value);} } public static readonly PropertyData WorldProperty = RegisterProperty("World", typeof(World)); } } Model:
namespace Library.Objects { using Catel.Data; using Catel.MVVM; public class World : ModelBase, INotifyPropertyChanged { [Model] public string Name { get { return GetValue<string>(NameProperty); } set { SetValue(NameProperty, value); } } public static readonly PropertyData NameProperty = RegisterProperty("Name", typeof(string), "Name"); [Model] public string Description { get { return GetValue<string>(DescriptionProperty); } set { SetValue(DescriptionProperty, value); } } public static readonly PropertyData DescriptionProperty = RegisterProperty("Description", typeof(string), "Description"); } } So pressing the button causes the correct function, i.e. binditsya normally and the fields do not want!