EventToCommand for Loaded event not working as expected if Window.SizeToContent = WidthAndHeight
Asked Answered
B

0

8

I find out that the EventToCommand for the Loaded-event is not working as expected if the Window.SizeToContent attribute is set to WidthAndHeight.

The Loaded-event seems to be fired correctly, but the EventToCommand.Command property is bound AFTER the Loaded event is fired.

If SizeToContent is Manual the Command will be bound BEFORE Loaded is fired and it works as expected.

Does anyone also have problems with this behavior and/or an explanation for this?

My workaround for now is to bind to the DataContext of the window:

<i:Interaction.Triggers>
  <i:EventTrigger EventName="Loaded" >
    <command:EventToCommand Command="{Binding ElementName=window, Path=DataContext.LoadedCommand}"/>
  </i:EventTrigger>
</i:Interaction.Triggers>
Boldfaced answered 17/9, 2015 at 9:48 Comment(5)
Did you get any information that? Is this a WPF bug? We've spent quite a lot of time on that issue.Carilyn
This obscure bug(?) is recently added dotnet github repository bug-tracker. I got bitten by this one too, slowly going insane thinking my XAML was some how borked. github.com/Microsoft/dotnet/issues/429Esmeraldaesmerelda
@Esmeraldaesmerelda ah, good to know... i'am used to think it's just my faultBoldfaced
@Carilyn it seems that the problem is still present. did not tested it by myself, but due to the comments on http://github.com/Microsoft/dotnet/issues/429Boldfaced
still present in net framework 6 - thanks for the workaroundExecration

© 2022 - 2024 — McMap. All rights reserved.