There is a form that can take any size. On this form there are 7 TextBlock with text of different lengths. It is necessary for TextBlock stretch across the entire width of the form observing the following parameters:
- If the
TextBlock1 character, then it must be a square. - All
TextBlockshould have the same height and the same font size.
Grid did not fit, because I need the same distance between the TextBlock . I also tried UniformGrid but it just stretches the elements, making them different in height. I tried the Viewbox , but I did not manage to achieve the desired results.
How can you achieve the desired result with the layout? I have a variant with an event for resizing a form to manually resize a TextBlock , but it seems to me a crutch. WPF is quite difficult for me to understand, so I decided to ask.
Form Code:
<Window x:Class="Test.Test" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Test" mc:Ignorable="d" Height="150" Width="500" WindowStyle="None" FontFamily="Arial" FontSize="14" ResizeMode="CanResizeWithGrip"> <StackPanel Orientation="Horizontal" Margin="5,0"> <Border Background="#FF323232" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Center" MinWidth="30" MinHeight="30"> <TextBlock Text="Rafd Hiljo" Foreground="#FFFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="7" /> </Border> <Border Background="#FF323232" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5" MinWidth="30" MinHeight="30"> <TextBlock Text="MD" Foreground="#FFFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="7" /> </Border> <Border Background="#FF323232" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5" MinWidth="30" MinHeight="30"> <TextBlock Text="T" Foreground="#FFFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="7" /> </Border> <Border Background="#FF323232" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5" MinWidth="30" MinHeight="30"> <TextBlock Text="Lader" Foreground="#FFFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="7" /> </Border> <Border Background="#FF323232" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5" MinWidth="30" MinHeight="30"> <TextBlock Text="W" Foreground="#FFFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="7" /> </Border> <Border Background="#FF323232" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5" MinWidth="30" MinHeight="30"> <TextBlock Text="Q" Foreground="#FFFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="7" /> </Border> <Border Background="#FF323232" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5" MinWidth="30" MinHeight="30"> <TextBlock Text="PAT" Foreground="#FFFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="7" /> </Border> </StackPanel> </Window> The form:
What I would like to achieve (arrows with the same color are equal):

