7

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>
jarlh
  • 42,561
  • 8
  • 45
  • 63
Sebastian
  • 73
  • 5
  • 1
    Did you get any information that? Is this a WPF bug? We've spent quite a lot of time on that issue. – Samuel Jun 20 '17 at 07:15
  • 1
    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. https://github.com/Microsoft/dotnet/issues/429 – Dribbel Jul 10 '17 at 18:46
  • @Dribbel ah, good to know... i'am used to think it's just my fault – Sebastian Oct 30 '18 at 10:30
  • @Samuel 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/429](http://github.com/Microsoft/dotnet/issues/429) – Sebastian Oct 30 '18 at 10:44

0 Answers0