WinUIEx
WinUIEx copied to clipboard
Deriving from WindowEx breaks bindings
When I derive from WindowEx scale of various UI elements are messed up on a 4K screen.
Wierdly enough my icons are too big and my texts are too small.
In any case it looks like it real messes the DPI awarness somehow.
Could you provide some more info? A reproducer and some screenshots would be helpful. I work on a 4K high dpi screen and have never seen this so would love to know more.
That is odd. It's on a closed source project which makes extensive use of Win32 APIs so maybe that's in combination with those API calls somehow.
If you’re able to distill the issue down to a smaller reproducer I would be able to take a look.
Yeah it's definitly not a DPI issue. Instead it somehow breaks access to some settings controlling the look and feel of the UI used by a derived class through XAML binding. Still really weird though.
The derived class has a list view with a data template for the list items and those list items are using binding to get some settings. Those bindings are broken somehow. Though it compiles and runs.
Here I name the class instance that now derives indirectly from WindowEx.
<local:WindowTaskbarBase
x:Class="Taskbar.WindowTaskbar"
x:Name="iMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Taskbar"
xmlns:lib="using:Taskbar;assembly=Taskbar.Lib"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
Activated="Window_Activated"
Closed="Window_Closed"
SizeChanged="iMainWindow_SizeChanged"
>
In the same XAML file I have the following to bind the settings:
<Image
Width ="{Binding ElementName=iMainWindow, Path=Settings.IconSize, Mode=OneWay}"
Height="{Binding ElementName=iMainWindow, Path=Settings.IconSize, Mode=OneWay}"
Margin="0"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Source="{x:Bind IconPath, Mode=OneWay}"
/>
What is iMainWindow? If it’s a window type that won’t work since it isn’t a dependency object. Try hardcoding the values in there just to rule out WinUIEx and confirm whether this is just a binding issue. Also does this happen if you don’t inherit from windowex but just from window?
I updated the post above. Everything works fine when not deriving from WindowEx.
To break it I just change:
internal class WindowBase : Microsoft.UI.Xaml.Window, INotifyPropertyChanged
to
internal class WindowBase : WindowEx, INotifyPropertyChanged
The settings class is using
ApplicationDataContainer iSettings = ApplicationData.Current.LocalSettings;
internally to store values. But the ones that are accessed from simplier bindings outside of the list items without having to use that iMainWindow are working fine.
@Slion If you could provide me with a small project that runs and reproduces the issue, I'd love to take a look.
Thanks, for now I've just postponed switching to WinUIEx until I find the time to investigate further.
Closing for now. If you get a chance to provide a repro, feel free to re-open.