I have a static class (Evp
), which is located in Models
folder. It has a Name
string, with getter and setter and a PropertyChangedEventHandler
and its code:
public static event PropertyChangedEventHandler StaticPropertyChanged;
private static string _name
public static string Name{
get => _name;
set{
_name = value;
OnStaticPropertyChanged("Name"); } }
private static void OnStaticPropertyChanged(string propertyName)
{
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(propertyName));
}
In my XAML file, this is how I tried to bind (it worked in WPF 4.5 if I recall correctly):
<Label Grid.Row="0" Grid.Column="1" TextColor="Beige" Text="{Binding Source={x:Static Models:Evp.Name}}" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="30"></Label>
I specified the Models
folder in the ContentPage
in XAML:
xmlns:Models="clr-namespace:Rdb.Models;assembly=Rdb"
For some reason, it's not working. What am I doing wrong? Also, how can I set this binding in code-behind?