WPF: Farba textoveho kurzora

Zmenit farbu kurzoru v TextBox-e nie je take jednoduche, ako by sa zdalo. Je to preto, ze WPF sa snazi tuto farbu udrziavat automaticky kontrastne ku farbe pozadia textboxu. Prave tuto vlastnost mozeme vyuzit

<Style TargetType="{x:Type TextBox}">
            <Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
            <Setter Property="AllowDrop" Value="true" />
            <Setter Property="Template">
                    <ControlTemplate TargetType="{x:Type TextBox}">
                            <Border x:Name="Border” BorderThickness="2"  SnapsToDevicePixels="True"  Padding="2" CornerRadius="2">
                                <ScrollViewer Margin="0" x:Name="PART_ContentHost" Style="{DynamicResource SimpleTextScrollViewer}"  />
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border" />
                                <Setter Property="BorderBrush" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border" />
                                <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}" />

Zdroj: Lester’s WPF\SL Blog

This entry was posted in Programovanie, WPF and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">