如何将一些文本放入文本框中,当用户在其中键入内容时会自动将其删除?(在WPF中)
我无法理解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这里的参考吗?(关于它的任何参考链接都很棒).
谢谢!
我有一个TextBox.我想检查它是否为空.
哪种方式更好
if(TextBox.Text.Length == 0)
Run Code Online (Sandbox Code Playgroud)
要么
if(TextBox.Text == '')
Run Code Online (Sandbox Code Playgroud)
?
c# ×3
wpf ×2
.net ×1
hint ×1
string ×1
textbox ×1
user-input ×1
validation ×1
watermark ×1
xaml ×1