0

I have made WPF project with window style of none (can resize) then I created custom taskbar on top with exit, maximize and minimize buttons. So exactly this.WindowState = WindowState.Normal; looks like this:

window state normal

when I press maximize button windows state changes to this.WindowState = WindowState.Maximized; and it does change but hiding some pixels on top and sides (probably on bottom too), see image bellow:

enter image description here

I'cant find anything about it on google and stackoverflow. So here is code am using to change window state:

        private void maximize_Click(object sender, RoutedEventArgs e)
        {
            if(this.WindowState == WindowState.Normal)
            {
                this.WindowState = WindowState.Maximized;
            } else
            {
                this.WindowState = WindowState.Normal;
            }
        }

and to make it maximized without hiding windows bottom taskbar am using this:

        public MainWindow()
        {
            InitializeComponent();
            MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth;
            MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
        }

I have found reason of this (but not fix yet):

    <WindowChrome.WindowChrome>
        <WindowChrome GlassFrameThickness="0" CornerRadius="0" CaptionHeight="0" 
            UseAeroCaptionButtons="False" ResizeBorderThickness="7" />
    </WindowChrome.WindowChrome>

if there is already question about but I couldn't find it please let me know

Ademn
  • 26
  • 5
  • The XAML would be more useful here, along with any global styles you may have set. My first guess would be margins, but without seeing the XAML it's hard to say – Avrohom Yisroel Dec 10 '22 at 21:18
  • This is expected as maximized windows are larger than they look on screen. – aybe Dec 10 '22 at 21:27
  • @AvrohomYisroel I haven't changed any global styles for my form. – Ademn Dec 10 '22 at 22:23
  • Well, the XAML for this window would still have been useful. However, see the comment by aybe, which sounds like it is the answer to your question. – Avrohom Yisroel Dec 10 '22 at 22:27
  • @AvrohomYisroel probably but what will be solution to fix it? – Ademn Dec 10 '22 at 22:29
  • As I keep saying, without seeing your XAML, it's very hard to help you – Avrohom Yisroel Dec 11 '22 at 11:11
  • @AvrohomYisroel I have posted my files on GitHub [link](https://github.com/Ademnn/WoTVTC) – Ademn Dec 11 '22 at 13:22
  • Please show the XAML for these buttons alone, without all the rest. Please post it in your question, so the question has the information we need. It's hard to read all that XAML and work out which bit creates those three buttons. – Avrohom Yisroel Dec 11 '22 at 14:08
  • @AvrohomYisroel found problem with WindowChrome but not solusion. Post updated with code of it. – Ademn Dec 11 '22 at 14:46
  • Hmm, not familiar with WindowChrome. Have you tried setting the vertical alignment of your elements to `center`? Seems th emost obvious fix. Other than that, I'm not sure – Avrohom Yisroel Dec 11 '22 at 14:48
  • Yeah, I have tried didn't work. – Ademn Dec 11 '22 at 16:00
  • There is already a similar question. https://stackoverflow.com/questions/29391063/wpf-maximized-window-bigger-than-screen – Andy Dec 11 '22 at 21:39

0 Answers0