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: CONTRIBUTING.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,4 +5,6 @@
5
5
- For typos and spelling mistakes feel free to provide a fix and they will be merged as long they comply with the owner's style guide.
6
6
- For code changes always open an issue first. This will allow to determine whether or not the change should take place. The issue should be used to discuss the change.
7
7
8
-
- If the pull request is accepted the project collaborators preserve the right to fix the code style before merging the changes
8
+
- If the pull request is accepted the project collaborators preserve the right to fix the code style before merging the changes.
9
+
10
+
- Pull requests must target the `develop` branch. Pull requests to the `master` branch will be declined.
The library allows to create `IValueConverter` and `IMultiValueConverter` objects with the most convenient syntax available, ideally, using the lambda expressions.
3
+
The library allows to create `IValueConverter`, `IMultiValueConverter`, `DataTemplateSelector`, and `ValidationRule` objects with the most convenient syntax available, ideally, using the lambda expressions.
4
+
5
+
## Lambda Value Converters
4
6
5
7
First create a (static) class and define your converters as static fields (or properties):
6
8
@@ -26,19 +28,93 @@ You're done! Just reference the converters with the `x:Static` expressions from
- resource declaration not needed, just use the `x:Static` expressions
32
34
- separate class for each converter not needed anymore
33
35
- no redundant declarations: if you do not need the `ConvertBack` method, don't define it; otherwise, just put the second lambda expression
34
36
- full support for the remaining parameters of the `Convert` and `ConvertBack` methods: the `culture` and the `parameter` (also strongly-typed) are accessible as well
35
37
- if the conversion fails due to unexpected value types the optional [error strategy](Sources/LambdaConverters.Wpf/ConverterErrorStrategy.cs) can be specified
36
38
37
-
:bulb:*ReSharper users*: use the Extension Manager to install the external annotations for the library.
39
+
## Lambda Data Template Selectors
40
+
41
+
The library also allows to create `DataTemplateSelector` objects in the same convenient way as value converters. In order to define a selector simply write a static field (or property) similar to this snippet:
Use your Lambda DataTemplateSelectors by referencing it with the `x:Static` markup extention (assuming that `s` is the namespace definition for the `TemplateSelector` class):
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.
72
+
73
+
### Features
74
+
-*strongly-typed* Selectors
75
+
- resource declaration not needed, just use the `x:Static` expressions
76
+
- separate class for each selector not needed anymore
77
+
- 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).
78
+
79
+
## Lambda Validation Rules
80
+
81
+
Furthermore, you'll get Lambda ValidationRules on top. By now you know "the drill". First, define a `ValidationRule`object like this:
82
+
83
+
```csharp
84
+
publicstaticclassRule
85
+
{
86
+
publicstaticValidationRuleIsNumericString=
87
+
LambdaConverters.Validator.Create<string>(
88
+
e=>e.Value.All(char.IsDigit)
89
+
?ValidationResult.ValidResult
90
+
:newValidationResult(false, "Text has non-digit characters!"));
91
+
}
92
+
```
93
+
And then reference your new rule in vour `View` (assuming that `r` is the namespace definition for the `Rule` class):
0 commit comments