[英]make custom window chrome with wpf
(this is a Q&A style question, I've answered it myself already) (这是一个问答式的问题,我自己已经回答过了)
" I'm making a custom window chrome in wpf but when I set it to windowStyle=none it “我正在 wpf 中制作自定义 window 镀铬,但是当我将其设置为 windowStyle=none 时
" "
solving problem 1解决问题1
make the main grid in the window accessible by name:使 window 中的主网格可以按名称访问:
<Grid Name="MainGrid">
then add these functions to create a margin when the window's state is changed然后添加这些函数以在窗口的 state 更改时创建边距
void setWinMargin()
{
switch (WindowState)
{
case WindowState.Maximized:
MainGrid.Margin = new Thickness(8, 8, 8, 8);
break;
case WindowState.Normal:
MainGrid.Margin = new Thickness(0, 0, 0, 0);
break;
}
}
private void Window_StateChanged(object sender, EventArgs e)
{
setWinMargin();
}
and this to you're xaml in your这对你来说是 xaml
StateChanged="Window_StateChanged"
StateChanged="Window_StateChanged"
what this will do is push everything away from the edges of the screen to be visible这将做的是将所有内容从屏幕边缘推开以可见
solving problem 2解决问题2
inside your window:在您的 window 内部:
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="35">
</WindowChrome>
</WindowChrome.WindowChrome>
make CaptionHeight your window chrome's height, where you want the window to be dragged by使 CaptionHeight 成为您的 window 铬的高度,您希望 window被拖动
solving problem 3解决问题3
don't use windowstate none, just define the windowchrome and the origional will be gone the buttons (on the right hand side) will still be there, just invisible, so you will have to put buttons over them不要使用windowstate none,只需定义windowchrome,原来的按钮就会消失,按钮(在右侧)仍然存在,只是不可见,所以你必须把按钮放在它们上面
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.