Reputation: 1097
I am looking to see if it is possible to hide the title bar and close button on a WPF User Control window.
I cannot use the WindowStyle="None" as this only relates to a window and not a User Control.
Any ideas?
Upvotes: 1
Views: 2846
Reputation: 50672
To turn off the title bar of the window on which the user control resides, you can add this to the code of the user control:
// walk up the tree to get the parent window
FrameworkElement parent = this.Parent;
while(parent != null && !parent is Window)
{
parent = parent.Parent;
}
// if window found, set style
if(parent != null && parent is Window)
{
parent.WindowStyle = WindowStyle.None;
}
Upvotes: 2