Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi friends,

I am creating a touch screen project in wpf. Now I set the window size Height="768" Width="1024" ; But i have a doubt! :doh:
How can I make it work on all sizes of monitor screens like 19inch and 25 inch touch screen? How to code my project?

I want the same in controls and their content should also fit for all screens!
I am waiting for your solution!.

Thank you. :)

My wpf window code is:
<window x:class="WPF.Window1" xmlns:x="#unknown">
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="DesktopKIOSK" Height="768" Width="1024" Loaded="Window_Loaded" WindowState="Maximized" WindowStyle="None"></window>

and my button code is:
<Button Canvas.Left="12" Canvas.Top="6" Height="74" Name="btn1" Width="305" Click="btn1_Click" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}" Focusable="False">
Posted
Updated 10-Feb-11 22:34pm
v2
Comments
JF2015 11-Feb-11 4:34am    
Edited to add code formatting.

There is no need to set height and width explicitly if you don't use Canvas. Use some other panel and use alignment or docking to position your elements.
 
Share this answer
 
Comments
Sagotharan Jagadeeswaran 11-Feb-11 12:09pm    
if i use other panel,. its enough?,..
Sergey Alexandrovich Kryukov 11-Feb-11 15:16pm    
No. See my answer.
--SA
Sergey Alexandrovich Kryukov 11-Feb-11 15:16pm    
Makes sense. Please see my more detailed answer.
--SA
Here is the way:

1) On the window classes, assign System.Windows.Window.SizeToContent to System.Windows.SizeToContent.WidthAndHeight.

2) Use flexible ("fluid") design on all inner elements would not depend on sizes. Never use absolute positions and sizes; keep them depending on contents. As a rule of thumb, only hard-coded numeric values in your XAML should be the values for Margin and Padding properties.

3) Use ResourceDictionary to keep all the margin and padding values consistent.

4) Prefer DockPanel, use splitters.

Application of those rules take certain experience. By the way, observing them will also help to keep your layout easy to globalize and ultimately localize.

Good luck,
—SA
 
Share this answer
 
v2
Comments
Sagotharan Jagadeeswaran 11-Feb-11 23:38pm    
Thank u For the more details,..
Sergey Alexandrovich Kryukov 12-Feb-11 0:04am    
I suggest you start developing WPF interfaces using this approach, so you will gain enough experience. Later on, you will enjoy good pay off: the code will also become way more supportable and more easy to change and reuse.
--SA
Sathish km 11-Sep-15 6:20am    
i'm new to wpf. want to develop desktop application for all screen resolution support. What to do?
Sergey Alexandrovich Kryukov 11-Sep-15 10:14am    
First of all, resolution (say, dots per inches) is irrelevant. You probably mean size of the screen in pixels. The solution is the same.
—SA
Sagotharan Jagadeeswaran 12-Feb-11 7:40am    
thank u

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900