Sebastian
Sebastian

Reputation: 83

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

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>

Upvotes: 8

Views: 1245

Answers (0)

Related Questions