1

i have a problem guys i made a wpf applications its running well but when i run the application on different screen resolution, then the controls(i.e. the size) added in the xbap page changes. So i want to get the current screen resolution and make the size of controls unchangable.Can anyone help me out.

thanks in advance Radhe Govind

<Window x:Class="MedSelectNew.ImageSelection"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
 xmlns:local="clr-namespace:MedSelectNew"   

Title="ImageSelection" WindowState="Maximized"  Loaded="Window_Loaded" ShowInTaskbar="False" WindowStyle="None" Background="Black" Width="{x:Static SystemParameters.PrimaryScreenWidth}" Height="{x:Static SystemParameters.PrimaryScreenHeight}" KeyDown="Window_KeyDown">

1
  • Doesn't specifying explicit sizes for each control achieve that ? (I'd recommend against this.. apps are supposed to render differently in different resolutions. e.g. I'd not like an app rendering huge buttons meant for 800v600 when I am on a 1920v1080 resolution display.
    – Gishu
    Jun 22, 2010 at 6:39

1 Answer 1

3

You can get the DPI-adjusted primary screen resolution from these properties:

SystemParameters.FullPrimaryScreenHeight
SystemParameters.FullPrimaryScreenWidth

It is not clear to me why you would want this, however. If you want your controls to be smaller when your window is smaller, just use WPF's layout capabilities along with ViewBox. If not, just give all your controls the same size. Either way I don't see how the current screen resolution comes into the picture.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.