KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is there anything wrong in WPF with setting the Owner property of a window to its parent in that parent's constructor? There shouldn't be, right? So why am I getting an XamlParseException from the following code? public partial class MainView : Window { private readonly OwnedWindow owned; public MainView() { InitializeComponent(); owned = new OwnedWindow(); owned.DataContext = DataContext; var window = GetWindow(this); owned.Owner = this; //Setting to window causes the same error ... } I should clarify that removing the owned.Owner = this; also removes the runtime error. The details of the exception: XamlParseException was unhandled The invocation of the constructor on type '...MainView' that matches the specified binding constraints threw an exception. Actually , I looked at the Inner Exception, and it says: Cannot set Owner property to a Window that has not been shown previously. So I'm looking into that now.
Tags (comma-separated)
Save Edits
Cancel