Answer the question
In order to leave comments, you need to log in
Property not firing in WPF. Where is the mistake?
In the markup below, the HorizontalAligment property of the TextBox elements does not work, I try to align them on the right side, but they do not respond, I tried to do this both with the help of styles and in the code itself.
<Window x:Class="Диплом.MainWindow"
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:Диплом"
mc:Ignorable="d"
Title="MainWindow"
Height="825" Width="1100"
MinHeight="825" MinWidth="550"
Background="White">
<Window.Resources>
<Style TargetType="StackPanel">
<Setter Property="Orientation" Value="Horizontal"/>
<Setter Property="Width" Value="500"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="HorizontalAlignment" Value="Right"/>
</Style>
</Window.Resources>
<Grid>
<Grid.Background>
<ImageBrush>
<ImageBrush.ImageSource>
C:\Users\User\Desktop\Диплом\Диплом\img\пту.jpeg
</ImageBrush.ImageSource>
</ImageBrush>
</Grid.Background>
<Border CornerRadius="40"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="700"
Height="750"
Padding="20">
<Border.Background>
<SolidColorBrush Color="White"
Opacity="0.75"/>
</Border.Background>
<StackPanel Orientation="Vertical"
Width="660">
<StackPanel>
<Label Content="Фамилия:"/>
<TextBox Width="300" HorizontalAlignment="Right"/>
</StackPanel>
<StackPanel>
<Label Content="Имя:"/>
<TextBox Width="300"/>
</StackPanel>
<StackPanel>
<Label Content="Отчество:"/>
<TextBox Width="300"/>
</StackPanel>
<StackPanel>
<Label Content="Телефон:"/>
<TextBox Width="300"/>
</StackPanel>
</StackPanel>
</Border>
</Grid>
</Window>
Answer the question
In order to leave comments, you need to log in
Use DockPanel instead of StackPanel
<DockPanel>
<Label Content="Фамилия:"/>
<TextBox Width="300" />
</DockPanel>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question