-
Notifications
You must be signed in to change notification settings - Fork 12
Converters
👉 To get started, make sure you have followed the getting started steps
Namespace: DIPS.Xamarin.UI.Converters
Namespace: DIPS.Xamarin.UI.Converters.ValueConverters
A converter that can be used with a Binding
to a boolean value. The converter will return a inverted boolean value.
Samples can be found here.
<Label Text="Welcome to Xamarin"
IsVisible="{Binding SomeLogicalProperty, Converter={dxui:InvertedBoolConverter}}" />
Namespace: DIPS.Xamarin.UI.Converters.ValueConverters
A converter that can be used with different input values. It will return a boolean value indicating whether or not the input value is empty. It also has the ability to be inverted.
Samples can be found here.
<Label Text="Is visible if list is empty"
IsVisible="{Binding EmptyListOfStrings, Converter={dxui:IsEmptyConverter}}" />
Namespace: DIPS.Xamarin.UI.Converters.ValueConverters
Converter that takes different input input types and returns a true/false object to indicate if it is empty or not. It also has the ability to be inverted.
Samples can be found here
<Label Opacity="{Binding MyText, Converter=IsEmptyToObjectConverter TrueObject=0, FalseObject=1}" />
Namespace: DIPS.Xamarin.UI.Converters.ValueConverters
Converters a boolean input value to its respective TrueObject
/FalseObject
. Can be used with any object and has the ability to be inverted.
Samples can be found here.
<Label Opacity="{Binding SomeLogicalProperty, Converter={dxui:BoolToObjectConverter TrueObject=0.5, FalseObject=1}}"
Text="My opacity changes" />
Converts an DateTime
object with a format and convert it to a readable time string
Samples can be found here
Format | English | Norwegian | Remarks |
---|---|---|---|
Default / Short | 12th Dec 2019 | 12. des 2019 | |
Text | Today | I dag | Will return different texts based on the date based on todays date |
<Label Text="{Binding Date, Converter={dxui:DateConverter Format=Default}}"
Converts an DateTime or TimeSpan object with a format and convert it to a readable time string
Samples can be found here
Format | English | Norwegian | Remarks |
---|---|---|---|
Default | 12:00 PM | 12:00 |
<Label Text="{Binding Time, Converter={dxui:TimeConverter Format=Default}}" />
Converters a DateTime object with an format and convert it to a readable string
Samples can be found here
Format | English | Norwegian | Remarks |
---|---|---|---|
Default / Short | 12th Dec 1990 12:00 PM | 12. des 1990 12:00 | |
Text | Today 12:00 PM | I dag, kl 12:00 | Will return different date texts based on the date based on todays date |
<Label Text="{Binding Date, Converter={dxui:DateAndTimeConverter Format=Default}}" />
Multiplies the input value with a provided factor.
Samples can be found here
<Label Text="{Binding Value, Converter={ValueConverters:MultiplicationConverter Factor=2}}" />
Adds the provided value (a term) with a Addend to create a sum
Samples can be found here
<Label Text="{Binding Value, Converter={dxui:AdditionConverter Addend=2}}" />
Looking for a way to string case your localized strings? See StringCase markup extension.
Converters a input string to a desired string case
Samples can be found here
<Label Text="{Binding MyString, Converter={dxui:StringCaseConverter StringCase=Upper}}"/>
Checks the type of the binding against a Type
and returns a True
/ False
object accordingly to the type check.
Samples can be found here
<Frame BackgroundColor="{Binding CurrentTypeClass, Converter={dxui:TypeToObjectConverter Type={x:Type valueconverters:OneTypeClass}, TrueObject=Red, FalseObject=Green}}" />
Converter that takes multiple boolean inputs, runs it through a LogicalGate
and returns a True
/FalseObject
.
👉 If
True
/FalseObject
is not set, it will returntrue
/false
Samples can be found here
<Label Text="MyText">
<Label.IsVisible>
<MultiBinding Converter="{dxui:LogicalExpressionConverter
LogicalGate=Or}">
<Binding Path="SomeBoolProperty" />
<Binding Path="SomeOtherBoolProperty" />
</MultiBinding>
</Label.IsVisible>
</Label>
These are the different options for logical gates:
A | B | Output |
---|---|---|
0 | 0 | 0 |
1 | 0 | 0 |
0 | 1 | 0 |
1 | 1 | 1 |
A | B | Output |
---|---|---|
0 | 0 | 1 |
1 | 0 | 1 |
0 | 1 | 1 |
1 | 1 | 0 |
A | B | Output |
---|---|---|
0 | 0 | 0 |
1 | 0 | 1 |
0 | 1 | 1 |
1 | 1 | 1 |
A | B | Output |
---|---|---|
0 | 0 | 1 |
1 | 0 | 0 |
0 | 1 | 0 |
1 | 1 | 0 |
A | B | Output |
---|---|---|
0 | 0 | 0 |
1 | 0 | 1 |
0 | 1 | 1 |
1 | 1 | 0 |
A | B | Output |
---|---|---|
0 | 0 | 1 |
1 | 0 | 0 |
0 | 1 | 0 |
1 | 1 | 1 |
- ContentControl
- DataTemplateSelectors
- Date- and TimePicker
- Modality
- Contextual Menus
- RadioButton
- TrendGraph
- Tag
- Toast