0

I'm brand new to WPF after using WinForms for years. I'm trying to get a window that looks like a typical windows form with the blue border and red close button, or really anything that has a border like it shows in the middle 2 windows of the Microsoft Docs. This is for .Net framework up to 4.8.1 but I am using .net 6.

border1

but my app always shows with no border: NoBorder

Here is my MainWindow.xaml:

<Window x:Class="Sim.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Sim"
        mc:Ignorable="d"
        Title="Simulator" Height="650" Width="1000"
        Icon="Resources/Sim.ico"
        WindowStyle="SingleBorderWindow">
    <Grid>
        <Button x:Name="Power" Content="Power" HorizontalAlignment="Left" Margin="84,84,0,0" VerticalAlignment="Top" Click="OnPowerClick"/>

    </Grid>
</Window>

I tried to add WindowChrome after WindowStyle="SingleBorderWindow">

    <Setter Property="shell:WindowChrome.WindowChrome">
        
    </Setter>

but I get the error "WindowChrome is not supported in a Windows Presentation Foundation (WPF) project."

Is there a way to get an older style border in .net 6 wpf?

Alexa Kirk
  • 152
  • 10
  • documentation states that pictures show the window styles on Windows Vista. do you have Windows Vista? – ASh Jan 24 '23 at 19:43
  • 1
    If I create a WinForms app on VS 2022, I get something close to your _chrome-less_ window on Win10. The only difference is that the client rect is a light WinForms-y grey. Windows appearance has always been determined (or at least greatly influenced by) the OS – Flydog57 Jan 24 '23 at 19:48
  • I am developing a .net6.0 wpf on Windows 10. Is there no way to get the older style border from .net framework 4.1 and/or Windows Vista? – Alexa Kirk Jan 24 '23 at 19:49
  • Did you search and try anything? Dunno if this works but I readily found https://stackoverflow.com/questions/2075720/windows-7-theme-for-wpf – Andy Jan 24 '23 at 20:07
  • Thanks @Andy I did search and documented what I tried. I did try the solution you linked to and it does not work. – Alexa Kirk Jan 24 '23 at 20:19
  • @Flydog57 Thanks for that. Based on your answer I just set the background of the main panel and that looks much better. – Alexa Kirk Jan 24 '23 at 20:40

0 Answers0