(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
"
solving problem 1
make the main grid in the window accessible by name:
<Grid Name="MainGrid">
then add these functions to create a margin when the window's state is changed
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
StateChanged="Window_StateChanged"
what this will do is push everything away from the edges of the screen to be visible
solving problem 2
inside your 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
solving problem 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.