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

帅比萌擦擦* 提交于 2019-12-22 05:06:00

问题


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>

来源:https://stackoverflow.com/questions/32627331/eventtocommand-for-loaded-event-not-working-as-expected-if-window-sizetocontent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!