-
[WPF] TextBox Placeholder, WartermarkC#/WPF 2024. 5. 16. 08:45
Just using XAML, no extensions, no converters:
<Grid> <TextBox Width="250" VerticalAlignment="Center" HorizontalAlignment="Left" x:Name="SearchTermTextBox" Margin="5"/> <TextBlock IsHitTestVisible="False" Text="Enter Search Term Here" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,0,0" Foreground="DarkGray"> <TextBlock.Style> <Style TargetType="{x:Type TextBlock}"> <Setter Property="Visibility" Value="Collapsed"/> <Style.Triggers> <DataTrigger Binding="{Binding Text, ElementName=SearchTermTextBox}" Value=""> <Setter Property="Visibility" Value="Visible"/> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> </Grid>
https://stackoverflow.com/questions/833943/watermark-hint-placeholder-text-in-textbox
728x90'C# > WPF' 카테고리의 다른 글
[WPF] Ioc resolve constructor parameter (0) 2024.06.07 [WPF] dotnet build (0) 2024.05.16 [WPF] LINQ (0) 2024.05.10 [WPF] Sta (0) 2024.04.26 [WPF] Install WPF (0) 2024.04.18 댓글