I have defined a RadWindow like this:
01.
<
telerik:RadWindow
x:Class
=
"Shell.ShellView"
03.
xmlns:x
=
"http://schemas.microsoft.com/winfx/2006/xaml"
04.
xmlns:mc
=
"http://schemas.openxmlformats.org/markup-compatibility/2006"
05.
xmlns:d
=
"http://schemas.microsoft.com/expression/blend/2008"
06.
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
07.
xmlns:shell
=
"clr-namespace:Shell"
08.
mc:Ignorable
=
"d"
09.
d:DesignHeight
=
"450"
d:DesignWidth
=
"800"
10.
d:DataContext
=
"{d:DesignInstance shell:ShellViewModel}"
11.
Width
=
"800"
12.
Height
=
"475"
13.
Header
=
"{Binding Header}"
14.
WindowStartupLocation
=
"{Binding StartupLocation}"
15.
navigation:RadWindowInteropHelper.ShowInTaskbar
=
"{Binding ShowInTaskBar}"
>
16.
[...]
17.
18.
</
telerik:RadWindow
>
Note the bindings on lines 13 - 15.
The corresponding view model looks like this:
01.
public
class
ShellViewModel
02.
{
03.
public
bool
ShowInTaskBar =>
true
;
04.
05.
public
WindowStartupLocation
StartupLocation => WindowStartupLocation.CenterScreen;
06.
07.
public
string
Header => Resources.MainWindowHeader;
08.
09.
[...]
10.
}
As you can see, I am binding the Header, the StartupLocation, and the ShowInTaskBar properties.
My problem is the following: while the bindings for the Header and ShowInTaskBar do work perfectly, the binding for StartupLocation doesn't. I understand why.
Can someone tell me what I am missing here?
Thanks in advance!
8 Answers, 1 is accepted
Hello Laurent,
Thank you for the provided code snippets.
Although the WindowStartupLocation is defined as a dependency property, the actual binding cannot be evaluated before the window is shown and that is why it appears as if it is not respected. You can notice that the native Window control does not allow binding to its WindowStartupLocation property at all.
We will try to think of a possible solution for this scenario, but in the meantime, you can manually transfer the value from the viewmodel to the window before showing the window:
var window = new ShellView();
var viewModel = new ShellViewModel();
window.DataContext = viewModel;
window.WindowStartupLocation = viewModel.StartupLocation;
window.Show();
Regards,
Dilyan Traykov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
Hello Laurent,
I'm happy to inform you that we've introduced a modification which should now allow you to bind the property as expected. It will be available with our next internal build on Monday (12.10).
Please let me know once you manage to test it out.
Regards,
Dilyan Traykov
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).
Hello Laurent,
The build should now be available for download in your Telerik account. Please inform me once you test it.
Regards,
Dilyan Traykov
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).
Dear Dilyan,
I can gladly confirm that your bugfix works.
Thanks a lot for your work!
Hi Laurent,
I'm happy to hear that the property now works as expected. Please let me know if you require any further assistance from my side.
Regards,
Dilyan Traykov
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.