Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: MaxHeight to screen height

Tags:

height

screen

wpf

how can I set the MaxHeight Property of a Window to screen height?

XAML:

<Window x:Class="RT.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="{Binding WindowTitle}" Height="300" MaxHeight="500" Width="495.149" SizeToContent="WidthAndHeight">
like image 527
sanjar14 Avatar asked Apr 02 '26 20:04

sanjar14


1 Answers

In the codebehind page of your control you can set the MaxHeight of your Window to

System.Windows.SystemParameters.PrimaryScreenHeight

or you can use SystemParameters.VirtualScreenHeight

like image 156
Krishna Avatar answered Apr 04 '26 10:04

Krishna



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!