Home > DeveloperSection > Forums > WPF APPLICATION
Jaya J
Jaya J

Total Post:9

Posted on    March-24-2015 10:24 PM

 .NET C# 

 1 Reply(s)
 888  View(s)
Rate this:
I want to change my TEXTBOX,LABEL,BUTTON SIZES dynamically based on screen resolutions. i.e, screen resolution of system may vary based on computer sizes.when i'm using my wpf application on different systems the sizes of TEXTBOX,LABEL, etc also change based on screen resolution.

Tell me the code for this problem.Please help me.

Mayank Tripathi
Mayank Tripathi

Total Post:397

Posted on    March-25-2015 4:46 AM

Hi Jaya , i have created a sample form as per your problem






<Window x:Class="WpfApplication1.MainWindow"
        Title="MainWindow" Height="350" Width="525" MinHeight="350">
        <Grid Height="Auto" Margin="2" Width="Auto">
                <RowDefinition Height="50"/>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="50"/>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="1*"/>
            <TextBlock Text="First Name" HorizontalAlignment="Stretch" VerticalAlignment="Center" Grid.Row="0"/>
            <Border BorderBrush="DarkGray" BorderThickness="1" Grid.Row="1" Margin="5" CornerRadius="5">
                <TextBox  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto"/>
            <TextBlock Text="Last Name" HorizontalAlignment="Stretch" VerticalAlignment="Center" Grid.Row="2"/>
            <Border BorderBrush="DarkGray" BorderThickness="1" Grid.Row="3"  Margin="5" CornerRadius="5">
            <TextBox  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  Width="Auto" Height="Auto"/>
            </Border >
            <Button Grid.Row="4"  Content="Button" HorizontalAlignment="Stretch" Width="Auto" Height="Auto" Margin="10" FontSize="30">



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
        public MainWindow()


Hope this will help u solve your problem!!



Don't want to miss updates? Please click the below button!

Follow MindStick