相关疑难解决方法(0)

水印/提示文本/占位符TextBox

如何将一些文本放入文本框中,当用户在其中键入内容时会自动将其删除?(在WPF中)

c# wpf textbox watermark hint

246
推荐指数
12
解决办法
21万
查看次数

此XAML代码中的IsEmpty引用/成员在哪里?

我无法理解IsEmpty这段代码(Path=Text.IsEmpty)(来自水印TextBox)的来源:

<Grid Grid.Row="0" Background="{StaticResource brushWatermarkBackground}" 
                   Style="{StaticResource EntryFieldStyle}" >
    <TextBlock Margin="5,2" Text="Type to search ..." Foreground="Gray"
               Visibility="{Binding ElementName=entry, Path=Text.IsEmpty, 
                          Converter={StaticResource BooleanToVisibilityConverter}}"/>
    <TextBox Name="entry" Background="Transparent"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)

你可以看到一个字符串没有任何IsEmpty属性.A DependencyProperty也没有任何IsEmpty成员.我甚至尝试在IsEmpty对象浏览器窗口中搜索,但没有任何相关结果解释代码.

你能解释一下IsEmpty这里的参考吗?(关于它的任何参考链接都很棒).

谢谢!

.net c# wpf xaml

9
推荐指数
1
解决办法
1446
查看次数

检查TextBox是否为空的最佳方法

我有一个TextBox.我想检查它是否为空.

哪种方式更好

if(TextBox.Text.Length == 0)
Run Code Online (Sandbox Code Playgroud)

要么

if(TextBox.Text == '')
Run Code Online (Sandbox Code Playgroud)

c# string validation user-input

5
推荐指数
2
解决办法
4万
查看次数

标签 统计

c# ×3

wpf ×2

.net ×1

hint ×1

string ×1

textbox ×1

user-input ×1

validation ×1

watermark ×1

xaml ×1