Hi Kasrkin212,
Welcome to our Microsoft Q&A platform!
If you want to update xaml after the property of the "Content" changed, you only need to assign a new value to Content.
Here is a simple demo.
xaml:
<ContentPage.BindingContext>
<local:MainPageViewModel/>
</ContentPage.BindingContext>
<StackLayout>
<Label Text="{Binding TestSource.Name}"/>
<Label Text="{Binding TestSource.Content.TranslationX}"/>
<Label Text="{Binding TestSource.Content.TranslationY}"/>
<Button Text="Chnage" Command="{Binding Source={RelativeSource AncestorType={x:Type local:MainPageViewModel}}, Path=ChangeCommand}"/>
</StackLayout>
xaml.cs:
class MainPageViewModel : INotifyPropertyChanged
{
Test testSource;
public Test TestSource
{
get => testSource;
set{
testSource = value;
OnPropertyChanged("TestSource");
}
}
public ICommand ChangeCommand { get; private set; }
public MainPageViewModel()
{
TestSource = new Test() { Name = "Test", Content = new ContentClass { TranslationX = 10, TranslationY = 10 } };
ChangeCommand = new Command(Change);
}
void Change()
{
// method I
TestSource.Content.TranslationX = 50;
OnPropertyChanged("TestSource");
// method II
Test temp = TestSource;
temp.Content.TranslationX = 50;
TestSource = temp;
// method III
TestSource = new Test() { Name = TestSource.Name, Content = new ContentClass { TranslationX = 50, TranslationY = TestSource.Content.TranslationY } };
}
// ...
}
Regards,
Kyle
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.