|
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SimpleControls.WatermarkTextBox;assembly=SimpleControls">
<!-- Define color of watermark in WatermarkTextBox name space -->
<SolidColorBrush x:Key="brushWatermarkForeground" Color="#99DDDDDD" />
<SolidColorBrush x:Key="brushWatermarkBackground" Color="Transparent" />
<Style TargetType="{x:Type local:TextBoxWithWatermark}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:TextBoxWithWatermark}">
<ControlTemplate.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<local:WatermarkHelper x:Key="WatermarkHelper" />
</ControlTemplate.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Content="{Binding Path=LabelTextBox, RelativeSource={RelativeSource FindAncestor, AncestorType=local:TextBoxWithWatermark, AncestorLevel=1}}"
HorizontalAlignment="Left" VerticalAlignment="Bottom"
Grid.Column="0" Grid.Row="0"/>
<TextBox Name="txtUserEntry1"
Text="{Binding Path=Text, RelativeSource={RelativeSource FindAncestor, AncestorType=local:TextBoxWithWatermark, AncestorLevel=1}}"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
Grid.Column="0" Grid.Row="1" />
<TextBlock Text="{Binding Path=Watermark, RelativeSource={RelativeSource FindAncestor, AncestorType=local:TextBoxWithWatermark, AncestorLevel=1}}"
Foreground="{StaticResource brushWatermarkForeground}"
Background="{StaticResource brushWatermarkBackground}"
VerticalAlignment="Center" HorizontalAlignment="Stretch"
IsHitTestVisible="False"
Grid.Column="0" Grid.Row="1" Margin="5,2">
<TextBlock.Visibility>
<Binding ElementName="txtUserEntry1" Path="Text.IsEmpty" Converter="{StaticResource BooleanToVisibilityConverter}" />
</TextBlock.Visibility>
</TextBlock>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
The Windows Presentation Foundation (WPF) and C# are among my favorites and so I developed
Edi
and a few other projects on
GitHub. I am normally an algorithms and structure type but WPF has such interesting UI sides that I cannot help myself but get into it.
https://de.linkedin.com/in/dirkbahle