Greetings!
I would like to set TitleBar and window Background colors to dynamic resources. How can I do that?
When I apply them, my variable is not applied or is set to transparent.
What can I do to make it work?
Best
Hi Joan,
We are still checking this reported query and have also forwarded it to our internal team to check on this. We will update you with further details on April 22, 2022.
Regards,
Sulthan Amanu
Hi Joan,
While setting transparent color, are you expecting the below UI for the windows and the title bar? Please note that the below screenshot is taken by setting a dark theme in the system settings. We will log a report once you provide confirmation of this behavior.
Regards,
Sulthan Amanu
I do not see such behaviour, unfortunately.
Plus to this I try to set Icon with DynamicResource and it also has no effect.
It is just not rendered.
Both variables for icon and for background are set in separate project in my solution and are added with resource merge.
For RibbonWindow this approach works, but for ChromelessWindow all my DynamicResources are
Hi Thilo,
We will validate the reported query and update the complete details on 2nd May, 2022.
Regards,
Sulthan Amanu
Hi Thilo,
We are unable to reproduce the reported issue at our end. We have attached the tested sample for your reference. Could you please share us more details such as complete code snippet or revert us by modify the attached sample to reproduce the issue which will be helpful us to provide the solution at earliest.
Regards,
Sulthan Amanu
Thank you!
I took a look and found that your *.xaml file is directly attached into App.xaml of project.
My issue is that *.xaml I use is loaded in runtime via Resources.MergedDictionaries in code behind.
Hi Joan,
We have modified the sample, so that it merges the resources at runtime via button click and it applies the dynamic background to the window correctly. We are facing the issue in icon only. Could you please check the attached sample and confirm us with more information about the issue which will be helpful for us to provide a solution as soon as possible?
|
private void AddResource_Click(object sender, RoutedEventArgs e) { Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("/ClassLibrary16;component/ThemeResources.xaml", UriKind.Relative) }); } |
Regards,
Prabakaran S
Greetings!
Thank you for update. Yes, I managed to fix issues with colors. Please let me know when issue with icon will also have a solution.
Hi Thilo,
You can resolve this by merging a resource dictionary file from another project before the "InitializeComponent" method of window. Then, it will properly update the icon from the resources during runtime.
|
public partial class MainWindow : ChromelessWindow { public MainWindow() { //Adding initial ResourceDictionary Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("/ClassLibrary16;component/ThemeResources1.xaml", UriKind.Relative) }); InitializeComponent(); }
private void AddResource_Click(object sender, RoutedEventArgs e) { //Adding Runtime ResourceDictionary Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("/ClassLibrary16;component/ThemeResources2.xaml", UriKind.Relative) }); } } |
Please let us know if you need any further assistance.
Regards,
Prabakaran S
Greetings!
I tested your approach too. Sorry, I guess I did not explained it through. I would like to set Icon in <Style> so I do not need to repeat Icon="{DynamicResource *}" in every single dialog I will create.
I tested in your lates example to set Icon via Style and it was not updated on theme resources or even on load change.
Best regards,
Thilo
Hi Thilo,
We have modified the sample based on your requirement with setting dynamic resource using Style. Please find the code snippet and sample below,
|
ThemeResources1.xaml:
<SolidColorBrush x:Key="WindowBackgroundColor" Color="LightCyan"/> <ImageSource x:Key="WindowIcon"> pack://application:,,,/ClassLibrary16;component//App1.ico </ImageSource>
<Style x:Key="ChromelessWindowCustomStyle" TargetType="syncfusion:ChromelessWindow"> <Style.Setters> <Setter Property="TitleBarBackground" Value="{DynamicResource WindowBackgroundColor}" /> <Setter Property="Background" Value="{DynamicResource WindowBackgroundColor}" /> <Setter Property="Icon" Value="{DynamicResource WindowIcon}" /> </Style.Setters> </Style>
MainWindow.xaml:
<syncfusion:ChromelessWindow x:Class="WpfApp6.MainWindow" xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:local="clr-namespace:WpfApp6" mc:Ignorable="d" xmlns:syncfusion=http://schemas.syncfusion.com/wpf Style="{DynamicResource ChromelessWindowCustomStyle}" WindowStartupLocation="CenterScreen" Title="MainWindow" Height="450" Width="800"> <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center"> <Button x:Name="addResource" Background="White" Content="Add New Resource" Width="200" Height="50" Click="AddResource_Click"/> </StackPanel> </shared:ChromelessWindow>
|
Please find the sample in the attachment and let us know if you have any other queries.
Regards,
Prabakaran S
Greetings!
Thank you for example you gave me.
I have only one question: will it be possible to have somethink like generic window style inheritance: <Style TargetType="syncfusion:ChromelessWindow" BasedOn="{DynamicResource CustomChromelessWindowStyle}"/>. I tried this in your example and Icon is ignored.
I have a lot of windows (not the MainWindow only) which will have ChromelessWindow base. So approach of setting style directly in dialog xaml, unfortunately, is not an answer to me.
Hope there is a solution.
Best regards,
Thilo
Hi Thilo,
We are currently checking the possibilities to achieve your requirement and will update the complete details or sample by tomorrow (13th May, 2022)
Regards,
Sulthan Amanu
Hi Thilo,
It is not possible to apply the generic window style like using the target type. We have checked with framework Window also, and it is not working. We have attached the tested sample for your reference.
If the attached sample does not similar like your requirement, please share us more details about your exact requirement or complete code snippet which will be helpful us to proceed further to provide the solution at the earliest.
Regards,
Sulthan Amanu
Greetings Sulthan!
Thank you for update.
Sad that it is not possible.
I will try to find a solution.
Thank you for you help!
Best Regards,
Thilo
Hi Thilo,
Please try at your end. Also, please let us know if you require any further assistance on this. we will be happy to assist you.
Regards,
Sulthan Amanu