开发者

User Control As Owner

I have window form in my WPF Application when I open new window from my form I used to set the owner of the new window to my opening wind开发者_如何学Cow. But when I have converted the parent window to user control the line

objSearchCareGiver.Owner = this;

gives error

Cannot implicitly convert type 'MyNameSpace.ucUserControlto 'System.Windows.Window' 

can anyone explain why is this so?


Do you get a runtime error or compile-time error? I'm guessing your error is because the Window.Owner property is of type Window and user controls aren't valid. Even if a user control is a subclass of Window it may be that user controls can't own child windows. Specifically, if you look at the documentation for the Window.Owner property, it talks about the property establishing a relationship between the parent and the child form. This relationship mostly has to to with propagating visual changes from the parent to the child (e.g., closing the child window automatically when the parent window is closed, minimizing the child when the parent is minimized). These behaviors don't really make sense with a user control as the parent.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜