2013-05-10 155 views
0

我在查看是否可以在WPF用户控件窗口中隐藏标题栏和关闭按钮。在WPF用户控件上隐藏标题栏

我不能使用WindowStyle =“None”,因为这只涉及到窗口而不是用户控件。

任何想法?

回答

1

要关闭窗口的标题栏,用户控件所在,您可以添加该用户控件的代码:

// 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; 
} 
+0

工作就像一个魅力。干杯。 – Nollaig 2013-05-13 09:12:35

+0

不客气。这就是我们在这里:) – 2013-05-13 09:56:32