Reputation: 141
I am working on an app where I am in need of changeing the text size from small to big with help of a settings page.
I have decoupled my code from the app.xaml and added some references there instread from some ResourceDictionary i've created.
I am now wondering if its possible to bind the value.
<Style x:Key="articleBodyText" TargetType="Label">
<Setter Property="FontSize" Value="{Binding SelectedFontSize}"/>
<Setter Property="Padding" Value="0,0,0,15"/>
<Setter Property="TextColor" Value="{AppThemeBinding Dark={StaticResource LightPrimaryColor}, Light={StaticResource DarkPrimaryColor}}"></Setter>
</Style>
Upvotes: 0
Views: 231
Reputation: 9701
Define a property of type double
private double _SelectedFontSize;
public double SelectedFontSize
{
get => _SelectedFontSize;
set => SetProperty(ref _SelectedFontSize, value); //INotifyProertyChanged
}
Supposed you have defined CustomSmall
resource either in xaml or in code:
Resources.Add("CustomSmall", 10);
Resources.Add("CustomLarge", 22);
Resources.TryGetValue("CustomSmall", out var fontSize);
FontSize = (double)fontSize;
Related question
Upvotes: 1
Reputation: 1
Value=new Binding(16) for example should set the Fontsize to 16. So you pass the chosen value from you're settings Page and use it in the binding.
Upvotes: 0