Hello ,
I am using Two theme in my project. And for each theme i set different type of font .
which is save in my database.
i change font from my App.Xaml .
like this
XAML<Style x:Key="TextBlockStyle" TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="{Binding Path= FontFamilyAsPerTheme,Source={x:Static Application.Current}}"/>
</Style>
and
XAML<Style x:Key="BaseUniversalStyle" TargetType="{x:Type Control}">
<Setter Property="FontFamily" Value="{Binding Path= FontFamilyAsPerTheme,Source={x:Static Application.Current}}"/>
</Style>
But i have face one problem. When i change the theme on that time, some part of UI has change the font but some are not.
when i restart my application then i get all font apply on UI.
so please suggest me solution where i can get change font run time.
for more detail i attach my video please check it. (I used MVVM pattern)
Thank you.
Hello,
Would you please describe how you set different types of font in different themes? A simple example that shows your current scenario will be very helpful.
Thanks,
Andrey
hello,
i do did following step.
I create one veritable on my App.cs
public static string FontFamilyAsPerTheme { get; set; }
and it's value i set on App.XAML design.
<Style x:Key="TextBlockStyle" TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="{Binding Path= FontFamilyAsPerTheme,Source={x:Static Application.Current}}"/>
<Setter Property="FontSize" Value="14"/>
</Style>
and
<Style x:Key="TextBlockStyle" TargetType="{x:Type TextBlock}">
<Setter Property="FontFamily" Value="{Binding Path= FontFamilyAsPerTheme,Source={x:Static Application.Current}}"/>
<Setter Property="FontSize" Value="14"/>
</Style>
when user change theme then i set new font value to variable as follow.
App.FontFamilyAsPerTheme = GeosApplication.Instance.UIThemeList.Where(uithe => uithe.ThemeName == ThemeManager.ApplicationThemeName).Select(ui => ui.FontFamily).FirstOrDefault();
AllowUIToUpdate();
void AllowUIToUpdate()
{
DispatcherFrame frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate (object parameter)
{
frame.Continue = false;
return null;
}), null);
Dispatcher.PushFrame(frame);
}
i just follow this 3 step.
in my project i have some class library which have some usercontrolls.
so i want to apply font to all UI which is used.
I thing by this description you can understand what i wan to say.
thank you
Hi,
I still don't fully understand how it is connected with our themes or controls. Would you please elaborate on it? Also in the code you provided I don't see that you change our theme. Can you provide us with a working example that shows your application? This way we will be able to find the cause of the issue and provide you with a solution.
Thanks,
Andrey
see my app files.
i have two theme.
and on selection of white theme i pass following code.
ThemeManager.ApplicationThemeName = "WhiteAndBlue";
App.FontFamilyAsPerTheme = GeosApplication.Instance.UIThemeList.Where(uithe => uithe.ThemeName == ThemeManager.ApplicationThemeName).Select(ui => ui.FontFamily).FirstOrDefault();
AllowUIToUpdate();