Owner="System.Windows.Application.Current.MainWindow"
won't work because "System.Windows.Application.Current.MainWindow" is just a string
Window.Owner
isn't a dependency property, so binding to static source ("{Binding Path=MainWindow, Source={x:Static Application.Current}}"
) won't work also
I modified App
class like this:
namespace WpfDemos
{
public partial class App : Application
{
public static Window CurrentMainWindow
{
get { return Current.MainWindow; }
}
}
}
and then in my window referenced that property via {x:Static}
extension:
<Window x:Class="WpfDemos.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wpfDemos="clr-namespace:WpfDemos"
Owner="{x:Static wpfDemos:App.CurrentMainWindow}"
so it is possible, but why?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…