0

I am new into WPF and i am developing a app with different images, textbox, etc. The problem is here on my screen it all looks ok according to the size of the window with the properties ive set on the window loaded:

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        Width = System.Windows.SystemParameters.PrimaryScreenWidth;
        Height = System.Windows.SystemParameters.PrimaryScreenHeight;
    }

When using the application on my screen it looks like this:

enter image description here

But when using it on a tablet i cant see the Calendar neither the text that says "Fecha nacimiento". Here is the WPF code i am using:

<Window x:Class="BiometricoRegistro.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="RegistrarCliente"  Height="978" Width="1600" Loaded="Window_Loaded" WindowState="Maximized">
    <Grid>
        <Grid.Background>
            <ImageBrush ImageSource="Imagenes\home_bg.jpg"/>
        </Grid.Background>
        <TextBox x:Name="txtbRut" HorizontalAlignment="Left" Height="51" TextWrapping="Wrap" BorderBrush="Transparent" VerticalAlignment="Top" Width="379" Margin="30,230,0,0" FontSize="35" FontWeight="Bold" PreviewTextInput="txtbRut_PreviewTextInput">
            <TextBox.Background>
                <ImageBrush ImageSource="Imagenes\input.png"/>
            </TextBox.Background>
        </TextBox>
        <TextBox x:Name="txtbRutVer" HorizontalAlignment="Left" Height="51" TextWrapping="Wrap" BorderBrush="Transparent" VerticalAlignment="Top" Width="74" Margin="430,230,0,0" FontSize="35" FontWeight="Bold" TextAlignment="Center">
            <TextBox.Background>
                <ImageBrush ImageSource="Imagenes\input.png"/>
            </TextBox.Background>
        </TextBox>
        <TextBox x:Name="txtbNombre" HorizontalAlignment="Left" Height="51" TextWrapping="Wrap" BorderBrush="Transparent" VerticalAlignment="Top" Width="474" Margin="30,330,0,0" FontSize="35" FontWeight="Bold">
            <TextBox.Background>
                <ImageBrush ImageSource="Imagenes\input.png"/>
            </TextBox.Background>
        </TextBox>
        <TextBox x:Name="txtbApellido" HorizontalAlignment="Left" Height="51" TextWrapping="Wrap" BorderBrush="Transparent" VerticalAlignment="Top" Width="474" Margin="30,430,0,0" FontSize="35" FontWeight="Bold">
            <TextBox.Background>
                <ImageBrush ImageSource="Imagenes\input.png"/>
            </TextBox.Background>
        </TextBox>
        <TextBox x:Name="txtbEmail" HorizontalAlignment="Left" Height="51" TextWrapping="Wrap" BorderBrush="Transparent" VerticalAlignment="Top" Width="474" Margin="30,530,0,0" FontSize="35" FontWeight="Bold">
            <TextBox.Background>
                <ImageBrush ImageSource="Imagenes\input.png"/>
            </TextBox.Background>
        </TextBox>
        <Calendar x:Name="calendar" HorizontalAlignment="Left" Height="170" VerticalAlignment="Top" Width="260" Margin="0,720,0,57"/>
        <Button x:Name="btnRegistrar" Content="Registrar" HorizontalAlignment="Center" Height="118" VerticalAlignment="Center" Width="296" Margin="775,0,221,100" Click="btnRegistrar_Click"/>
        <ComboBox x:Name="cbPorcentaje" HorizontalAlignment="Left" Height="40" Margin="30,630,0,0" VerticalAlignment="Top" Width="230" HorizontalContentAlignment="Center" FontSize="35">
            <ComboBoxItem Content="A" FontSize="35"></ComboBoxItem>
            <ComboBoxItem Content="B" FontSize="35"></ComboBoxItem>
            <ComboBoxItem Content="C" FontSize="35"></ComboBoxItem>
        </ComboBox>
        <TextBlock HorizontalAlignment="Left" Height="37" Margin="30,176,0,0" TextWrapping="Wrap" Text="Rut cliente" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
        <TextBlock HorizontalAlignment="Left" Height="37" Margin="30,286,0,0" TextWrapping="Wrap" Text="Nombres cliente" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
        <TextBlock HorizontalAlignment="Left" Height="37" Margin="30,386,0,0" TextWrapping="Wrap" Text="Apellidos cliente" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
        <TextBlock HorizontalAlignment="Left" Height="37" Margin="30,486,0,0" TextWrapping="Wrap" Text="Email cliente" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
        <TextBlock HorizontalAlignment="Left" Height="37" Margin="30,586,0,0" TextWrapping="Wrap" Text="Tipo Descuento" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
        <TextBlock HorizontalAlignment="Left" Height="37" Margin="30,678,0,230" TextWrapping="Wrap" Text="Fecha nacimiento" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
        <TextBlock x:Name="txtResult" HorizontalAlignment="Left" Height="64" Margin="501,0,0,57" TextWrapping="Wrap" Text="" VerticalAlignment="Bottom" Width="823" FontSize="46" Foreground="Red" FontFamily="PMingLiU-ExtB"/>
    </Grid>
</Window>
5
  • Controls positions of the your window are absolute so you can't see some of them on the tablet. You should make positions relative Commented Sep 16, 2014 at 4:31
  • Also add your grid inside a scrollViewer, you scroll down your controls. Commented Sep 16, 2014 at 4:33
  • You mean margins are absolute? because most of my controls are HorizontalAlignment="left" and VerticalAlignment="top" how i can make them relative? Commented Sep 16, 2014 at 4:33
  • 1
    @ffenix Try using RowDefinitions and ColumnDefinitions? Commented Sep 16, 2014 at 4:36
  • @ffenix Yeah, margins are absolute. And also you put all controls in one Grid's cell so you should use RowDefinitions and ColumnDefinition as har07 said. Commented Sep 16, 2014 at 4:43

1 Answer 1

2
  1. Always use appropriate panels . I would prefer Dock and stackpanel with splitters.
  2. assign System.Windows.Window.SizeToContent to System.Windows.SizeToContent.WidthAndHeight.
  3. Use Resource Dictonary for consistency of margins and other values
  4. I would not prefer to use Absolute positions. decide your margin values depending on your content .
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you i am using a dock panel now with stack panels inside

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.