Good day. I developed the application on a 4: 3 monitor and now bought 16: 9. At 4: 3 it is almost full screen and at 16: 9 almost nothing is visible. How to deal with this?

I would like to implement the mode in the whole window. But again, the elements remain in place only the window is stretched. How to increase them and leave in the same place?

When there is a lot of a piece, maybe if I finish it then I will do everything else according to the principle

<StackPanel Margin="0,90,0,0" Height="360" VerticalAlignment="Top" > <TabControl x:Name="MainTab" Height="393" Margin="0,-34,0,0" Background="{x:Null}" BorderBrush="{x:Null}" > <TabItem Header="Anastasia" Style="{DynamicResource TabButtons}" Margin="16,2,-16,-2" > <Grid HorizontalAlignment="Left" Width="311"> <TextBox x:Name="UserMessage" Margin="0,0,0,10" Background="{x:Null}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="300" Foreground="White" KeyDown="UserMessage_KeyDown" PreviewKeyDown="UserMessage_PreviewKeyDown" > <TextBox.BorderBrush> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF00E2C3" Offset="0"/> <GradientStop Color="#FF5100C7" Offset="1"/> </LinearGradientBrush> </TextBox.BorderBrush> </TextBox> <ListView x:Name="MainChat" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" Background="{x:Null}" Margin="5,191,0,39" IsEnabled="False" Foreground="White" BorderBrush="{x:Null}" ItemTemplateSelector="{StaticResource TS}" ItemsSource="{Binding TempSelect}" Style="{DynamicResource ListViewStyle}" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" Width="304" > </ListView> <Label x:Name="UserCommand" Height="37" Margin="0,-5.5,0.333,294.5" Foreground="White" FontSize="16" HorizontalAlignment="Right" Grid.Column="1" d:LayoutOverrides="TopMargin, BottomMargin" /> <Button x:Name="SendButt" Content="{x:Static p:Resources.SendMessageButton}" Height="22.162" Margin="232,333,0,9" Style="{DynamicResource MainButtons}" Click="SendButt_Click" HorizontalAlignment="Left" Width="75"/> <Label x:Name="UserCommandShow" Margin="0,157,4,139" Foreground="White" FontSize="16" FontFamily="Adobe Caslon Pro Bold" HorizontalAlignment="Right" /> </Grid> </TabItem> 

  • What to do with the text? - VladD
  • one
    A properly written application is stretched by itself, with the exception of texts. But this is if you did not align the Margins. - VladD
  • one
    Without code it is difficult to say something. Show some markup. - Ev_Hyper
  • one
    Exactly, leveling out marginals. Here you have created problems for yourself. - VladD
  • 2
    They went overboard with the use of a “handy” tool for adding controls. XAML need to write with your hands, or at least edit. - RusArt

1 answer 1

Everything is bad. You do not use layout management, but position the elements using manually hard-coded margins. Not surprisingly, your UI does not scale - and what did you want? Your code does exactly what you told it.

For your case there should be something like this:

 <!-- stackpanel вовсе не нужен, он не даёт растянуться --> <!-- маргин убрать, фиксированную высоту убрать --> <!-- вам точно нужен null-background, или подойдёт background по умолчанию? --> <TabControl x:Name="MainTab" Background="{x:Null}" BorderBrush="{x:Null}" Margin="5"> <!-- это что такое за маргин? сдвиг вправо? зачем? убрать! --> <TabItem Header="Anastasia"> <!-- а зачем alignment не по всей ширине? --> <Grid> <!-- так, форматируем при помощи строк в Grid --> <Grid.RowDefinitions> <!-- Этот кусок занимает как можно больше места --> <RowDefinition Height="*"/> <!-- Этот занимает сколько ему нужно, не больше --> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <!-- утащили вверх и поместили в первую строку --> <!-- ну вы поняли насчёт маргина и фиксированной ширины --> <!-- а зачем RenderTransformOrigin o_O --> <ListView x:Name="MainChat" Grid.Row="0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled" Background="{x:Null}" IsEnabled="False" Foreground="White" BorderBrush="{x:Null}" ItemsSource="{Binding TempSelect}"/> <!-- а сообщение и кнопку упакуем в свой контейнер --> <DockPanel LastChildFill="True" Grid.Row="1"> <Button x:Name="SendButt" Content="Send Message" DockPanel.Dock="Left"/> <!-- опять фиксированная ширина, убрать, лэйаутом занимается контейнер --> <TextBox x:Name="UserMessage" Background="{x:Null}" Foreground="White" Padding="2"> <TextBox.BorderBrush> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF00E2C3" Offset="0"/> <GradientStop Color="#FF5100C7" Offset="1"/> </LinearGradientBrush> </TextBox.BorderBrush> </TextBox> </DockPanel> <!-- не знаю, куда вы хотели её поместить, разбирайтесь сами --> <Label x:Name="UserCommand" Foreground="White" FontSize="16" HorizontalAlignment="Right" /> <!-- и с этой тоже --> <Label x:Name="UserCommandShow" Foreground="White" FontSize="16" FontFamily="Adobe Caslon Pro Bold" HorizontalAlignment="Right" /> </Grid> </TabItem> </TabControl> 

It turns out something like this:

picture

and it resizes correctly when the window is resized. Stylize and direct the beauty further yourself.

  • one
    In our office, too, there are lovers of stumbling controls from the toolbox. :) - iRumba