WPF Text Fields and Borders - Curious Resizing

The following XAML creates a window with strange behavior around a text field:

<Window x:Class="WpfSandbox.CuriousExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="CuriousExample" Height="300" Width="300">
    <DockPanel Margin="15">
        <TextBox BorderThickness="1" BorderBrush="#FF000000"></TextBox>
    </DockPanel>
</Window>

What happens, at least during my limited testing, is that the text box is rendered using the insert border pattern (top / left black, gray on the right / bottom). However, when you resize to any position other than the original, the entire border of the text box becomes black. Whenever you return a window to the exact number of screen pixels that the form had when it was loaded, it is inserted again.

I assume this is not a pixel snap, as I can easily fix the problem with this code:

<Window x:Class="WpfSandbox.CuriousExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="CuriousExample" Height="300" Width="300">
    <DockPanel Margin="15">
        <Border BorderThickness="1" BorderBrush="#FF000000">
            <TextBox BorderThickness="0" ></TextBox>
        </Border>
    </DockPanel>
</Window>

Anyone want to explain to me what I see? Or is it all in my head?

, - , .

,

-

+3
2

vista (aero)

app.xaml - :

    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component/themes/aero.normalcolor.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

PresentationFramework.Aero .

XP, Vista.

0

... ? Aero, TextBox, TextBox . , TextBox, :

<DockPanel Margin="15">
    <TextBox BorderThickness="1" BorderBrush="#FF000000"></TextBox>
    <TextBox BorderThickness="1" BorderBrush="#FF000000"></TextBox>
</DockPanel>

Aero ControlTemplate, TextBox ListBoxChrome, , .

Luna Border BorderBrush TemplateBinding, , ( XP/Luna, 2008 Vista).

0

Source: https://habr.com/ru/post/1710510/


All Articles