V
V
vilix2016-03-17 18:51:02
WPF
vilix, 2016-03-17 18:51:02

On execution, the edges of the window in WPF are clipped. What is the problem here?

Is it supposed to cut like this on win 8?
fdd80c250ba34966a739536ffc96892c.png
And I still don’t understand why SizeToContent="Height" sets the same size of the form to 210, it looks the same in the designer, but nothing is cut off at runtime. But some kind of black spruce noticeable stripe appears at the bottom of the form.
2705c1796e0e49e48baf739e1c5f5567.png
XAML is normal and with two fields, labels and a button, if necessary, I will attach it.
XAML:

<Window  x:Class="OkClient.LoginWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Авторизация" Width="287.166"
        ResizeMode="NoResize"
        SizeToContent="Height"
        SaveWindowPosition="True">
    <StackPanel>
        <Label Visibility="Collapsed" Content="Неверные данные авторизации" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Margin="10,7,10,0" VerticalAlignment="Top" Width="261" Foreground="Red"/>
        <Label Content="Логин:" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Top" Padding="0,5,5,5" FontSize="16" Width="149"/>
        <TextBox x:Name="loginTxt" HorizontalAlignment="Center" Margin="0,0,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="150" FontSize="16" Padding="5"/>
        <Label Content="Пароль:" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Top" Width="149" Padding="0,5,5,5" FontSize="16"/>
        <PasswordBox x:Name="passwordTxt" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Top" Width="150" Padding="5" FontSize="16"/>
        <Button
            FontSize="16"
            Content="Войти" 
            HorizontalAlignment="Center" 
            Margin="0,10,0,10" 
            VerticalAlignment="Top" 
            Width="150"
            Height="33"/>
    </StackPanel>
</Window>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Pavlov, 2016-03-17
@vilix

I can’t check it myself, I can see everything well (I have Win7).
Try clearing all appearance settings. Will it be visible?

<StackPanel>
    <Label Visibility="Collapsed" Content="Неверные данные авторизации" HorizontalAlignment="Center" Margin="10,7,10,0" Width="Auto" Foreground="Red"/>
    <Label Content="Логин:"/>
    <TextBox x:Name="loginTxt" TextWrapping="NoWrap"/>
    <Label Content="Пароль:"/>
    <PasswordBox x:Name="passwordTxt"/>
    <Button Content="Войти"/>
</StackPanel>

If it does not change, then remove the attributes in Window.
If it works, then gradually return the attributes to the elements. Or set a common style for all elements at once so that all elements have the same styles:
<Window.Resources>
    <Style x:Key="CommonStyle" TargetType="Control">
        <Setter Property="Margin" Value="5" />
        <Setter Property="Padding" Value="5" />
        <Setter Property="FontSize" Value="16"/>
        <Setter Property="Width" Value="150"/>
    </Style>
    <Style TargetType="Label" BasedOn="{StaticResource CommonStyle}"/>
    <Style TargetType="TextBox" BasedOn="{StaticResource CommonStyle}"/>
    <Style TargetType="PasswordBox" BasedOn="{StaticResource CommonStyle}"/>
    <Style TargetType="Button" BasedOn="{StaticResource CommonStyle}"/>
</Window.Resources>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question