Difference between revisions of "Converters In Xamarin"
Line 1: | Line 1: | ||
− | This page lists all currently available converters for customizing Xamarin XAML. | + | This page lists all currently available converters for customizing Xamarin XAML. Examples on how to use these converters will follow soon. |
+ | Also, this page and the listed converters are subject to change! | ||
{| class="wikitable sortable" | {| class="wikitable sortable" | ||
Line 19: | Line 20: | ||
| ClassificationToBoolConverter || style="text-align: center;" | ✗ || Returns a '''boolean''' indicating whether the given '''ContentViewModel''' is successfully classified. | | ClassificationToBoolConverter || style="text-align: center;" | ✗ || Returns a '''boolean''' indicating whether the given '''ContentViewModel''' is successfully classified. | ||
|- | |- | ||
− | | ContainsToBoolConverter || style="text-align: center;" | ✗ || Checks if the delivered value is '''contained''' within a collection of values (delivered in the parameter, seperated with <nowiki>|</nowiki>). If the value is contained, ''true'' will be returned, else ''false''. The functionality is similar to the ''ContainsToVisibilityConverter'' in the WinX project. | + | | ContainsToBoolConverter || style="text-align: center;" | ✗ || Checks if the delivered value is '''contained''' within a collection of values (delivered in the parameter, seperated with <code><nowiki>|</nowiki></code>). If the value is contained, ''true'' will be returned, else ''false''. The functionality is similar to the ''ContainsToVisibilityConverter'' in the WinX project. |
|- | |- | ||
| ContainsToInvertedBoolConverter || style="text-align: center;" | ✗ || Same as the ''ContainsToBoolConverter'', but with '''inverted output'''. The functionality is similar to the ''ContainsToVisibilityConverter'' in the WinX project. | | ContainsToInvertedBoolConverter || style="text-align: center;" | ✗ || Same as the ''ContainsToBoolConverter'', but with '''inverted output'''. The functionality is similar to the ''ContainsToVisibilityConverter'' in the WinX project. | ||
Line 25: | Line 26: | ||
| ContentAreaTeamplateConverter || style="text-align: center;" | ✗ || This converter is '''not yet finished''' and just returns the ''UBIKContentArea'' if the value is a ''ContentViewModel''. | | ContentAreaTeamplateConverter || style="text-align: center;" | ✗ || This converter is '''not yet finished''' and just returns the ''UBIKContentArea'' if the value is a ''ContentViewModel''. | ||
|- | |- | ||
− | | DateTimeOffsetToDateConverter || style="text-align: center;" | ✓ || Converts a '''[https://docs.microsoft.com/en-us/dotnet/api/system.datetimeoffset DateTimeOffset]''' to the correct '''[https://docs.microsoft.com/en-us/dotnet/api/system.datetime DateTime]'''. If the value cannot be interpreted, a new ''DateTime'', generated from the device's current time ( | + | | DateTimeOffsetToDateConverter || style="text-align: center;" | ✓ || Converts a '''[https://docs.microsoft.com/en-us/dotnet/api/system.datetimeoffset DateTimeOffset]''' to the correct '''[https://docs.microsoft.com/en-us/dotnet/api/system.datetime DateTime]'''. If the value cannot be interpreted, a new ''DateTime'', generated from the device's current time (<code>DateTime.Now</code>) is returned. |
|- | |- | ||
| DateTimeToFromNowStringConverter || style="text-align: center;" | ✗ || Returns a '''[https://docs.microsoft.com/en-us/dotnet/api/system.datetime DateTime]''' into a human-readable and easily understandable ''string message'' (the last applying one will be taken): | | DateTimeToFromNowStringConverter || style="text-align: center;" | ✗ || Returns a '''[https://docs.microsoft.com/en-us/dotnet/api/system.datetime DateTime]''' into a human-readable and easily understandable ''string message'' (the last applying one will be taken): | ||
Line 44: | Line 45: | ||
| EqualityToInvertedBoolConverter || style="text-align: center;" | ✗ || Returns ''true'' if the given value and parameter are '''not equal to each other''', ''false'' otherwise. | | EqualityToInvertedBoolConverter || style="text-align: center;" | ✗ || Returns ''true'' if the given value and parameter are '''not equal to each other''', ''false'' otherwise. | ||
|- | |- | ||
− | | SelectionChangedEventArgsConverter || style="text-align: center;" | ✗ || Converts an '''[https://help.syncfusion.com/cr/cref_files/xamarin/Syncfusion.SfListView.XForms~Syncfusion.ListView.XForms.ItemSelectionChangedEventArgs.html Syncfusion ItemSelectionChangedEventArgs]''' to a '''[https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.selectionchangedeventargs ListSelectionChangedEventArgs]'''. The use-case of this converter is highly specific. | + | | SelectionChangedEventArgsConverter || style="text-align: center;" | ✗ || Converts an '''[https://help.syncfusion.com/cr/cref_files/xamarin/Syncfusion.SfListView.XForms~Syncfusion.ListView.XForms.ItemSelectionChangedEventArgs.html Syncfusion ItemSelectionChangedEventArgs]''' to a '''[https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.selectionchangedeventargs ListSelectionChangedEventArgs]'''. <br/>The use-case of this converter is highly specific. |
|- | |- | ||
| FilterCriterionToValueConverter || style="text-align: center;" | ✓ || Converts a '''FilterCriterion''' to its value. The functionality is similar to UWP's FilterCriterionToValueConverter. | | FilterCriterionToValueConverter || style="text-align: center;" | ✓ || Converts a '''FilterCriterion''' to its value. The functionality is similar to UWP's FilterCriterionToValueConverter. | ||
Line 61: | Line 62: | ||
| NullToInvertedBoolConverter || style="text-align: center;" | ✓ || ''Null'' or an '''empty string''' value get converted to ''false'', and everything else to ''true''. | | NullToInvertedBoolConverter || style="text-align: center;" | ✓ || ''Null'' or an '''empty string''' value get converted to ''false'', and everything else to ''true''. | ||
|- | |- | ||
− | | PathToImageSourceValueConverter || style="text-align: center;" | | + | | PathToImageSourceValueConverter || style="text-align: center;" | ✗ || Reads the '''path''' provided as parameter and creates an '''image source''' from it. |
+ | |- | ||
+ | | PercentageToProgressConverter || style="text-align: center;" | ✗ || The '''numeric value''' (int or double), interpreted as '''percentage from 0 to 100''', get converted to a '''progress level''' (0 to 1). Values outside this range will be contained. | ||
+ | |- | ||
+ | | PropertyNameExistsToBoolConverter || style="text-align: center;" | ✗ || Converts a property to a '''boolean statment''' based on its '''existence'''. If it exists, ''true'' will be returned, else ''false'' or ''null'' (if something couldn't be properly interpreted). | ||
+ | |- | ||
+ | | PropertyNameExistsToInvertedBoolConverter || style="text-align: center;" | ✗ || Converts a property to a '''boolean statment''' based on its '''existence'''. If it exists, ''false'' will be returned, else ''true'' or ''null'' (if something couldn't be properly interpreted). | ||
+ | |- | ||
+ | | RootAreaTemplateConverter || style="text-align: center;" | ✗ || If the provided value is '''not null''', the '''UBIKRootArea template''' will be returned. | ||
+ | |- | ||
+ | | SelectiveItemToValueConverter || style="text-align: center;" | ✓ || Converts a item of a selective list to its value. | ||
+ | |- | ||
+ | | SelectiveListToItemsConverter || style="text-align: center;" | ✗ || Returns all items from a selective list. | ||
+ | |- | ||
+ | | SfDataSourceConverter || style="text-align: center;" | ✗ || It's an advanced converter used for '''loading items''' and '''applying filters''' on it. It replaces to ''CollectionToViewConverter'' from the WinX.UWP project. The datasource can be directly used with a ''[https://help.syncfusion.com/xamarin/sflistview/overview SfListView]''. | ||
+ | |- | ||
+ | | StringContainsToBoolConverter || style="text-align: center;" | ✗ || Returns a '''boolean''' indicating whether the parameter string is included in the value string. | ||
+ | |- | ||
+ | | StringContainsToInvertedBoolConverter || style="text-align: center;" | ✗ || Same as the ''StringContainsToBoolConverter'' but with '''inverted output'''. | ||
+ | |- | ||
+ | | StringFormatConverter || style="text-align: center;" | ✗ || TBD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
+ | |- | ||
+ | | ToStringFormatConverter || style="text-align: center;" | ✗ || Converts '''primitives''' or '''[https://docs.microsoft.com/en-us/dotnet/api/system.datetime DateTime]''' to string and allows the application of '''[https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings formatting options]''' (as parameter). <br/>Adding a <code>.</code> to the end of the format-parameter allows '''[https://docs.microsoft.com/en-us/dotnet/api/system.math.truncate truncation]''' of all decimal places. | ||
+ | |- | ||
+ | | ToTypeConverter || style="text-align: center;" | ✗ || Attempts to convert value to the Type specified in parameter. | ||
+ | |- | ||
+ | | TypeNameToBoolConverter || style="text-align: center;" | ✗ || Returns ''true'' if the type name of the value is present in the parameter-string (seperated by <code><nowiki>|</nowiki></code>). | ||
+ | |- | ||
+ | | TypeNameToInvertedBoolConverter || style="text-align: center;" | ✗ || Inverted ''TypeNameToBoolConverter''. | ||
+ | |- | ||
+ | | ValueValidityToBoolConverter || style="text-align: center;" | ✗ || Returns ''true'' if the given ''ValueValidity'' has a '''higher importance''' than ''OK'' or ''Undefined''. | ||
+ | |- | ||
+ | | ValueValidityToInvertedBoolConverter || style="text-align: center;" | ✗ || Inverted ''ValueValidityToBoolConverter''. | ||
+ | |- | ||
+ | | DataTemplateItemTemplateSelectorConverter || style="text-align: center;" | ✗ || Chooses what '''ChildItemTemplateSelector''' to return. Having a parameter with the content "Small" returns the small item template selector. | ||
+ | |- | ||
+ | | DataTemplateItemsPanelConverter || style="text-align: center;" | ✗ || Chooses what '''ItemPanelTemplate''' to return. Having a parameter with the content "Small" returns the small item template selector. | ||
|} | |} | ||
− | |||
===Usage=== | ===Usage=== | ||
− | + | This description will follow soon! |
Revision as of 15:45, 1 August 2019
This page lists all currently available converters for customizing Xamarin XAML. Examples on how to use these converters will follow soon. Also, this page and the listed converters are subject to change!
Converter | 2-Way | Description |
---|---|---|
BooleanConverter | ✓ | Interprets the boolean value and returns it. If the value cannot be interpreted, false is returned. |
BooleanInvertConverter | ✓ | Interprets and converts a boolean into its inverted value. If the value cannot be interpreted, false is returned. |
BooleanToFontAttributeConverter | ✗ | Converts a boolean into a [font attribute] value. In detail, if the value is true, the parameter is interpreted (Bold, Italic, None) and returned. The default returned font-attribute is None. |
ByteToImageSourceValueConverter | ✗ | Converts a byte stream value into an image source. |
ChildAreaTemplateConverter | ✗ | Returns a ChildAreaTemplate from a ContentViewModel or null if the ViewModel cannot be interpreted. |
ChildItemSelectionModeToSfListViewSelectionModeConverter | ✓ | Converts a ChildItemSelectionMode to [Syncfusion's ListViewSelectionMode]. Default is "Single". |
ClassificationToBoolConverter | ✗ | Returns a boolean indicating whether the given ContentViewModel is successfully classified. |
ContainsToBoolConverter | ✗ | Checks if the delivered value is contained within a collection of values (delivered in the parameter, seperated with | ). If the value is contained, true will be returned, else false. The functionality is similar to the ContainsToVisibilityConverter in the WinX project.
|
ContainsToInvertedBoolConverter | ✗ | Same as the ContainsToBoolConverter, but with inverted output. The functionality is similar to the ContainsToVisibilityConverter in the WinX project. |
ContentAreaTeamplateConverter | ✗ | This converter is not yet finished and just returns the UBIKContentArea if the value is a ContentViewModel. |
DateTimeOffsetToDateConverter | ✓ | Converts a DateTimeOffset to the correct DateTime. If the value cannot be interpreted, a new DateTime, generated from the device's current time (DateTime.Now ) is returned.
|
DateTimeToFromNowStringConverter | ✗ | Returns a DateTime into a human-readable and easily understandable string message (the last applying one will be taken):
|
DebugConverter | ✓ | A converter returning the given value for debug reasons. |
DistanceToStringConverter | ✗ | Returns the given value interpreted as length. Values are returned in kilometers with two comma digits (e.g. 2.84km), values smaller than 1km are returned as meters and NaN will be returned as infinity. If the value cannot be interpreted, an empty string will be returned. |
EqualityToBoolConverter | ✗ | Returns true if the given value and parameter are equal to each other, false otherwise. |
EqualityToInvertedBoolConverter | ✗ | Returns true if the given value and parameter are not equal to each other, false otherwise. |
SelectionChangedEventArgsConverter | ✗ | Converts an Syncfusion ItemSelectionChangedEventArgs to a ListSelectionChangedEventArgs. The use-case of this converter is highly specific. |
FilterCriterionToValueConverter | ✓ | Converts a FilterCriterion to its value. The functionality is similar to UWP's FilterCriterionToValueConverter. |
GuidPropertyValueConverter | ✓ | Returns the first item of the parameter's Source-ViewModel that matches the given GUID value. If none is found, null is returned. |
IntToColorConverter | ✗ | Converts an integer value to a color. If the value cannot be interpreted, the converter tries to parse the parameter as a color to return it. If everything fails, transparent is returned. |
ItemCountToBoolConverter | ✗ | This converter has a property to set the boolean return value, called LesserThanReturnValue. This property-value will be returned if the given value is smaller than or equal to the threshold (parameter, defaults to 0). If the value is bigger than the threshold, the inverted LesserThanReturnValue will be returned. In any other case (like the value cannot be interpreted), false is returned, so it's a good idea to set the converter's property in a way that the return is only true if you need it. |
ItemCountToOverflowConverter | ✗ | Creates a human-readable text indicating how many items are available. The value will be interpreted as the total item count and the parameter as overflow threshold (defaults to 99). If there are more items than the overflow, the overflow value with a + sign will be returned (e.g. 99+). If not, the value itself will be returned. If everything fails, null is returned. |
NullToBoolConverter | ✓ | Null or an empty string value get converted to true, and everything else to false. |
NullToInvertedBoolConverter | ✓ | Null or an empty string value get converted to false, and everything else to true. |
PathToImageSourceValueConverter | ✗ | Reads the path provided as parameter and creates an image source from it. |
PercentageToProgressConverter | ✗ | The numeric value (int or double), interpreted as percentage from 0 to 100, get converted to a progress level (0 to 1). Values outside this range will be contained. |
PropertyNameExistsToBoolConverter | ✗ | Converts a property to a boolean statment based on its existence. If it exists, true will be returned, else false or null (if something couldn't be properly interpreted). |
PropertyNameExistsToInvertedBoolConverter | ✗ | Converts a property to a boolean statment based on its existence. If it exists, false will be returned, else true or null (if something couldn't be properly interpreted). |
RootAreaTemplateConverter | ✗ | If the provided value is not null, the UBIKRootArea template will be returned. |
SelectiveItemToValueConverter | ✓ | Converts a item of a selective list to its value. |
SelectiveListToItemsConverter | ✗ | Returns all items from a selective list. |
SfDataSourceConverter | ✗ | It's an advanced converter used for loading items and applying filters on it. It replaces to CollectionToViewConverter from the WinX.UWP project. The datasource can be directly used with a SfListView. |
StringContainsToBoolConverter | ✗ | Returns a boolean indicating whether the parameter string is included in the value string. |
StringContainsToInvertedBoolConverter | ✗ | Same as the StringContainsToBoolConverter but with inverted output. |
StringFormatConverter | ✗ | TBD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
ToStringFormatConverter | ✗ | Converts primitives or DateTime to string and allows the application of formatting options (as parameter). Adding a . to the end of the format-parameter allows truncation of all decimal places.
|
ToTypeConverter | ✗ | Attempts to convert value to the Type specified in parameter. |
TypeNameToBoolConverter | ✗ | Returns true if the type name of the value is present in the parameter-string (seperated by | ).
|
TypeNameToInvertedBoolConverter | ✗ | Inverted TypeNameToBoolConverter. |
ValueValidityToBoolConverter | ✗ | Returns true if the given ValueValidity has a higher importance than OK or Undefined. |
ValueValidityToInvertedBoolConverter | ✗ | Inverted ValueValidityToBoolConverter. |
DataTemplateItemTemplateSelectorConverter | ✗ | Chooses what ChildItemTemplateSelector to return. Having a parameter with the content "Small" returns the small item template selector. |
DataTemplateItemsPanelConverter | ✗ | Chooses what ItemPanelTemplate to return. Having a parameter with the content "Small" returns the small item template selector. |
Usage
This description will follow soon!