I have a custom control in Xamarin.Forms app that's described via XAML. For example, CustomControl.xaml:
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
x:Class="Sample.CustomControl">
<Ellipse Fill="White"
WidthRequest="32"
HeightRequest="32">
</Ellipse>
</ContentView>
And corresponding CustomControl.xaml.cs:
public partial class CustomControl: ContentView
{
public CustomControl()
{
InitializeComponent();
}
}
If I use this control in my MainPage.xaml and set some of its' properties, they are applied correct at startup, but then if I try to change any of values at runtime, nothing happens.
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:Sample;assembly=Sample"
x:Class="Sample.MainPage">
<StackLayout>
<AbsoluteLayout VerticalOptions="FillAndExpand">
<controls:CustomControl x:Name="CustomControl"
AbsoluteLayout.LayoutBounds="0.5, 0.5" // <- At startup this control is positioned in center but then if I change this property at runtime layout doesn't rearrange
AbsoluteLayout.LayoutFlags="PositionProportional">
</controls:CustomControl>
</AbsoluteLayout>
</StackLayout>
</ContentPage>
At the same time, if I move those properties from MainPage.xaml to the root level of CustomControl.xaml.cs and change them at runtime, layout rearranges like expected:
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
x:Class="Sample.CustomControl"
AbsoluteLayout.LayoutBounds="0.5, 0.5" // <- If I place this property in child's XAML and change it at runtime the position of element changes
AbsoluteLayout.LayoutFlags="PositionProportional">
<Ellipse Fill="White"
WidthRequest="32"
HeightRequest="32">
</Ellipse>
</ContentView>
Maybe this thing is related to XAML hot reload, because binding of that property works in both cases, no matter where I set property binding (at 'control' level or at 'page' level). Could someone explain, why changing property value in page XAML file at runtime doesn't cause any updates?
UPDATE 24.04.2022
I found the solution. I had to change 'Hot Reload mode' to 'Full page' in VS settings. Now during debug session every change that I make to XAML files is reflected immediately.
