Skip to content

Instantly share code, notes, and snippets.

@ionoy
Last active February 23, 2017 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ionoy/89cc6005be77ca3f99bfafe093f8c2d8 to your computer and use it in GitHub Desktop.
Save ionoy/89cc6005be77ca3f99bfafe093f8c2d8 to your computer and use it in GitHub Desktop.
TextBox {
#Watermark(bindingPath: "Xaml", watermarkText: "Insert XAML here")
}
mixin Watermark(bindingPath, watermarkText) for TextBox {
Style: combine Style {
TargetType: TextBox
Triggers: [
DataTrigger {
Binding: bind $bindingPath convert (string str) => string.IsNullOrEmpty(str)
Value: true
#Setter("Text", $watermarkText)
#Setter("Opacity", 0.3)
}
DataTrigger {
Binding: bind IsFocused from $this
Value: true
#Setter("Opacity", 1)
#Setter("Text", bind Xaml)
}
DataTrigger {
Binding: bind $bindingPath convert (string str) => !string.IsNullOrEmpty(str)
Value: true
#Setter("Text", bind Xaml)
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment