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
  •  | 
  •  

Question

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.

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top