What property is set on the parent window when a child window is shown using showdialog()?

StackOverflow https://stackoverflow.com/questions/21702984

  •  09-10-2022
  •  | 
  •  

I have a custom window and would like to apply a custom style to the window when it cannot be accessed due to it having a child window (displayed via showdialog()). I assumed that the trigger property would be "IsEnabled", however this property is not set to false when showdialog() is called. I have also tried "Focusable" and looked through the list of properties in hope of finding the obvious solution. This led to me trying a data trigger which binds to "OwnedWindows.Count" but again this doesn't work! Surely this should be simple and I am missing something?

Triggers tried:

 <Trigger Property="IsEnabled" Value="False">

 <Trigger Property="Focusable" Value="False">

 <DataTrigger Binding="{Binding Path=OwnedWindows.Count, RelativeSource={RelativeSource Self}}" Value="1" >

Note: Both IsEnabled and Focusable do the required job when I manually set the properties to False - so I know the trigger works, they just aren't being set when ShowDialog() is called.

有帮助吗?

解决方案

There is no property like that. Use ComponentDispatcher.EnterThreadModal and ComponentDispatcher.LeaveThreadModal events instead. They are fired when a WPF modal dialog is shown or closed, respectively.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top