You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+78Lines changed: 78 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,84 @@ You're done! Just reference the converters with the `x:Static` expressions from
36
36
37
37
:bulb:*ReSharper users*: use the Extension Manager to install the external annotations for the library.
38
38
39
+
## Lambda DataTemplateSelectors
40
+
41
+
The library also allows to create `DataTemplateSelector` objects in the same convenient way as Converters. In order to define a Selector simply write a static field (or property) similar to this snippet:
Tada! All even numbers from `IntNumbers` are displayed with black font and white background and the odd numbers get the inverse font and background colors.
76
+
77
+
### Features
78
+
-*strongly-typed* Selectors
79
+
- resource declaration not needed, just use the `x:Static` expressions
80
+
- separate class for each selector not needed anymore
81
+
- full support for the remaining parameter `container`. For example, if you need to grab a `DataTemplate` from where the selector is use (see the example above).
82
+
83
+
## Lambda ValidationRules
84
+
85
+
Furthermore, you'll get Lambda ValidationRules on top. By now you know "the drill". First, define a `ValidationRule`object like this:
86
+
87
+
```csharp
88
+
publicstaticclassRule
89
+
{
90
+
publicstaticValidationRuleIsNumericString=
91
+
LambdaConverters.Validator.Create<string>(
92
+
e=>e.Value.ToCharArray().All(char.IsDigit)
93
+
?ValidationResult.ValidResult
94
+
:newValidationResult(false, "Text has non-digit characters!"));
0 commit comments