InvalidOperationException when closing a RadWindow opened on a separated UI thread. The exception message is: "Cannot use a DependencyObject that belongs to a different thread than its parent Freezable."
To work this around, you can merge the Telerik.Windows.Controls.Navigation.xaml dictionary in the Resources of all RadWindow instances open on another thread and then set their Style property to the RadWindowStyle from the merged .xaml dictionary.
<telerik:RadWindow x:Class="WpfApp84.Window1"
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:WpfApp84" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable="d" Height="450" Width="800" Style="{DynamicResource RadWindowStyle}">
<telerik:RadWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Telerik.Windows.Controls.Navigation;component/Themes/GenericWindows11.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</telerik:RadWindow.Resources>
</telerik:RadWindow>
Switching the Windows 11 theme's color variation to a different one is not correctly applied with the Mica effect. This is present when the Windows 11 version is 22621.
A temporary resolution is to stop the Mica effect by setting the WindowEffectsHelper.BackdropMaterial property on the RadWindow to None.
<telerik:RadWindow x:Class="Example.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:helpers="clr-namespace:Telerik.Windows.Controls.Theming.Helpers;assembly=Telerik.Windows.Controls"
helpers:WindowEffectsHelper.BackdropMaterial="None"
Header="RadWindow">
An alternative approach would be to use DynamicResource when basing the custom style for the RadWindow on its default one. Also, when changing the color variation, the merged resource dictionaries could be cleared and then merged again. This way, the Mica effect will not have to be turned off.
<telerik:RadWindow xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="Example.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:WindowWindows11ThemeTest"
mc:Ignorable="d"
Style="{DynamicResource RadWindowStyle}"
Header="MainWindow" Height="450" Width="800">
private bool isDarkPalette;
private void RadButton_Click(object sender, RoutedEventArgs e)
{
if (this.isDarkPalette)
{
Windows11Palette.LoadPreset(Windows11Palette.ColorVariation.System);
this.isDarkPalette = false;
}
else
{
Windows11Palette.LoadPreset(Windows11Palette.ColorVariation.Dark);
this.isDarkPalette = true;
}
this.MergeDictionaries();
}
private void MergeDictionaries()
{
Application.Current.Resources.MergedDictionaries.Clear();
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
{
Source = new Uri("/Telerik.Windows.Themes.Windows11;component/Themes/System.Windows.xaml", UriKind.RelativeOrAbsolute)
});
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
{
Source = new Uri("/Telerik.Windows.Themes.Windows11;component/Themes/Telerik.Windows.Controls.xaml", UriKind.RelativeOrAbsolute)
});
Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
{
Source = new Uri("/Telerik.Windows.Themes.Windows11;component/Themes/Telerik.Windows.Controls.Navigation.xaml", UriKind.RelativeOrAbsolute)
});
}
Hi,
our company is slowly rolling out high-DPI laptops to our users. On such devices, Windows automatically enables DPI scaling, using a value of 125% or 150%, depending on the screen's resolution. In combination with an external (unscaled) monitor, this causes our application, to appear blurry on the scaled screen.
Windows has built-in functionality to reduce the blurring, however, this only works on the main screen. If you connect a secondary screen and set that as your main screen, the application will always appear blurry on the laptop screen.
My understanding of the topic is that WPF is DPI aware - but on the system level. So it does not cope well with monitors that have different DPI settings. However, I found a tutorial on Microsoft Docs (https://docs.microsoft.com/en-gb/windows/win32/hidpi/declaring-managed-apps-dpi-aware?redirectedfrom=MSDN), hinting that it is possible to make WPF windows per-monitor DPI aware. Unfortunately, this workaround requires you to inherit your window class from their utility class.
Since all of our windows already inherit from RadWindow, I have no chance to include this without copying either their base class or RadWindow. Having RadWindow support per-monitor DPI awareness would be a great feature to have. Or is there already a way to support this?
Best Regards,
Simon Müller
Hofmann Fördertechnik GmbH
PS: Why does the first feature form in the feature request workflow (the one, where it first searches for similar requests) not let me select the control/area I am searching for like the one for private tickets? I almost submitted this request for the Area "All (Multiple Controls)" because of that.
Tested with 16.8.4 - works as expected. Updated to 16.9.0 to match the client's setup and managed to reproduce the issue. The issue is reproducible also with the 16.10.0 version of Visual Studio.
Hi,
Please see attached project,
After use animation changed window size and use the mouse to drag to change the size of the window,
When the window size is smaller than the original size, the upper right button will be hide,
Original WPF Window no this problem, And changing size animation very Smooth then RadWIndow.
If you open the window on a specific resolution, maximize it and then change the resolution to a bigger one, the window size is not updated. The window stays in the original resolution of the screen.
To work this around subscribe to the SystemEvents.DisplaySettingsChanged event and reset the WindowState of RadWindow.
public MainWindow() // where MainWindow is RadWindow
{
InitializeComponent();
SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;
}
private void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e)
{
if (this.WindowState == WindowState.Maximized)
{
this.WindowState = WindowState.Normal;
this.WindowState = WindowState.Maximized;
}
}
There should be an easy method to add/override the shadow of a RadWindow. Either via XAML attributes or code behind.
It would probably be good to allow the override of BlurRadius, Direction, and ShadowDepth.<telerik:RadWindow x:Class="MyRadWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
Header="Settings" WindowStartupLocation="CenterOwner" SizeToContent="True" ResizeMode="NoResize" MinWidth="500" MaxWidth="900" DropShadowOverride="True" DropShadowOverrideBlurRadius="10" DropShadowOverrideDirection"-90", DropShadowOverrideDepth="3" DropShadowOverrideColor="White">
<Grid>
<!-- UI code -->
</Grid>
</telerik:RadWindow>