Click here to Skip to main content
16,017,852 members
Please Sign up or sign in to vote.
1.44/5 (3 votes)
See more:
I have developed windows application in WPF. After creating exe i installed in another computer it is working fine. But when i installed in YAN(projector) the buttons text design is not appearing properly as it is coming in my computer.

when i changed the resolution in projector Page is looking small and not aligned. please help me.
Posted
Updated 2-Oct-18 21:41pm
Comments
Sergey Alexandrovich Kryukov 8-Sep-15 9:11am    
What you observe simply tells us that you just don't have proper WPF application. Instead of "fitting screen resolution" (it's not really resolution, this is just screen size in pixels, resolution is something different and irrelevant), you should avoid fixed layout and develop fluid layout which adopts well to any size of the window. Stop using any manual sizing and positioning.
—SA

Use Horizontal Alignment & Vertical Alignment properties to align controls inside WPF windows. And use Margin to set padding for controls.
 
Share this answer
 
Comments
Member 11959194 8-Sep-15 7:27am    
can you give some more clear explanation
Horizontal Alignment Property is used to align controls horizontally. It has 4 options.
1. Left
2. Center
3. Right
4. Stretch

Like above, Vertical Alignment Property is used to align controls vertically. It also has 4 options.
1. Top
2. Center
3. Bottom
4. Stretch

Margin property used to specify the distance for the control from Left, Top, Right, Bottom corners. The above properties are very important in placing controls in a WPF window.

I'll explain this with small example. Consider a button inside the window.
<Button Content="Button" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="150,140,150,140"/>

Here, HorizontalAlignment is set to Stretch, it means, the button will be stretched to fit when the window is resized. This is same for VerticalAlignment property.

Margin: Left = 150, Top = 140, Right = 150, Bottom = 140 - these margin values placing the button 140 pixel distance from Top and Bottom, also places the button 150 pixel distance from Left and Right.

Now if your resizes the screen, the button will be placed according to the margin, and the button wil be stretched to fit the window.
 
Share this answer
 
Comments
Member 11959194 9-Sep-15 3:13am    
Thank you
if you are hosting your wpf app inside another window that is your main window is in different file then to wrap data inside it use viewbox with Stretch property equal to "Fill".
the whole data will wrapped according to size of window.
 
Share this answer
 

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