{"id":16243920,"url":"https://github.com/emako/valueconverters.avalonia","last_synced_at":"2026-02-24T07:32:25.934Z","repository":{"id":237173201,"uuid":"793987231","full_name":"emako/ValueConverters.Avalonia","owner":"emako","description":"An Avalonia library ported from ValueConverters.NET.","archived":false,"fork":false,"pushed_at":"2024-10-01T06:37:29.000Z","size":91,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-29T20:57:52.059Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emako.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-30T08:41:13.000Z","updated_at":"2025-10-24T17:41:20.000Z","dependencies_parsed_at":"2024-09-06T18:08:37.117Z","dependency_job_id":"f1ae5203-776b-400e-a993-c53671b81008","html_url":"https://github.com/emako/ValueConverters.Avalonia","commit_stats":null,"previous_names":["emako/valueconverters.avalonia"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/emako/ValueConverters.Avalonia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emako%2FValueConverters.Avalonia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emako%2FValueConverters.Avalonia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emako%2FValueConverters.Avalonia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emako%2FValueConverters.Avalonia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emako","download_url":"https://codeload.github.com/emako/ValueConverters.Avalonia/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emako%2FValueConverters.Avalonia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29774913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T04:54:30.205Z","status":"ssl_error","status_checked_at":"2026-02-24T04:53:58.628Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T14:16:52.974Z","updated_at":"2026-02-24T07:32:25.900Z","avatar_url":"https://github.com/emako.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ValueConverters.NET \n[![Version](https://img.shields.io/nuget/v/ValueConverters.Avalonia.svg)](https://www.nuget.org/packages/ValueConverters.Avalonia)  [![Downloads](https://img.shields.io/nuget/dt/ValueConverters.Avalonia.svg)](https://www.nuget.org/packages/ValueConverters.Avalonia)\n\nAn Avalonia library ported from [ValueConverters.NET](https://github.com/thomasgalliker/ValueConverters.NET).\n\nThis library contains a collection of most commonly used implementations of the IValueConverter interface. ValueConverters are used to convert values bound from the view to the view model - and in some cases also backwards.\n\n### Download and Install ValueConverters \n\nThis library is available on NuGet: [ https://www.nuget.org/packages/ValueConverters.Avalonia/]( https://www.nuget.org/packages/ValueConverters.Avalonia/) \n\n\n### API Usage \n\nThe usage of converters is on all platforms more or less the same: \n* Define the converter in the resources area of the view/page/usercontrol. \n* Use the converter in a binding by referenceing  it as a StaticResource. \n\n#### General Usage of Converters in XAML \n\nDefine a converter in the Resources section of a UserControl, Window, Page, etc. Specify options if required. \n\n```xaml\n\u003cUserControl.Resources\u003e\n    \u003cResourceDictionary\u003e\n        \u003cconverters:DateTimeConverter x:Key=\"DateTimeConverter\" Format=\"d\" MinValueString=\"-\"/\u003e\n    \u003c/ResourceDictionary\u003e\n\u003c/UserControl.Resources\u003e\n```\n\nApply the converter as a StaticResource: \n\n```xaml\n\u003cTextBox Text=\"{Binding EmployeeDetailViewModel.Birthdate, Converter={StaticResource DateTimeConverter}}\"/\u003e \n```\n\n#### Using EnumWrapperConverter \n\nEnumWrapperConverter is used to display localized enums. The concept is fairly simple: Enums are annotated with localized string resources and wrapped into EnumWrapper\u003cTEnumType\u003e. The view uses the EnumWrapperConverter to extract the localized\nstring resource from the resx file. Following step-by-step instructions show how to localize and bind a simple enum type in a WPF view:\n\n1) Define new public enum type and annotate enum values with [Display] attributes: \n\n```c#\n[DataContract] \npublic enum PartyMode \n{ \n    [EnumMember] \n    [Display(Name = \"PartyMode_Off\", ResourceType = typeof(PartyModeResources))] \n    Off, \n\n    // … \n}\n```\n\n3) Create StringResources.resx and define strings with appropriate keys (e.g. \"PartyMode__Off\"). Make sure PublicResXFileCodeGenerator is used to generate the .Designer.cs file. (If ResXFileCodeGenerator is used, the resource lookup operations may require more time to complete).\n\n4) Create StringResources.resx for other languages (e.g. StringResources.de.resx) and translate all strings accordingly. Use [Multilingual App Toolkit]( https://visualstudiogallery.msdn.microsoft.com/6dab9154-a7e1-46e4-bbfa-18b5e81df520) \nfor easy localization of the defined string resources. \n\n5) Expose enum property in the ViewModel. \n\n```c#\npublic PartyMode PartyMode \n{ \n    get { return this.partyMode; } \n    set { this.partyMode = value; \n         this.OnPropertyChanged(() =\u003e this.PartyMode); } \n} \n```\n\n6) Bind to enum property in the View and define Converter={StaticResource EnumWrapperConverter}. \n\n```xaml\n\u003cLabel Content=\"{Binding PartyMode, Converter={StaticResource EnumWrapperConverter}}\" /\u003e \n```\n\nThat’s it. If you want to change the UI language at runtime, don’t forget to call OnPropertyChanged after changing CurrentUICulture. There is a WPF sample app available. \n\n### Converter Culture\nValue converters are culture-aware. Both the Convert and ConvertBack methods have a culture parameter that indicates the cultural information. If cultural information is irrelevant to the conversion, then you can ignore that parameter in your custom converter.\n\nBy default, the culture parameter is provided by the underlaying platform. If you want to override the provided culture, use the property PreferredCulture. You can select from one of the following override behaviors:\n- **PreferredCulture.ConverterCulture**: Default, uses the converter culture provided by the underlying platform.\n- **ConverterCulture.CurrentCulture**: Overrides the default converter culture with CultureInfo.CurrentCulture.\n- **ConverterCulture.CurrentUICulture**: Overrides the default converter culture with CultureInfo.CurrentUICulture.\n\nThis is particularly helpful in WPF applications, since it is a known/unresolved bug that the provided culture parameter does not update when CultureInfo.CurrentCulture or CultureInfo.CurrentUICulture is updated.\nUse **ValueConvertersConfig.DefaultPreferredCulture** to configure the default converter culture for all converters.\n\n### Links\n\n- System.Windows.Data.IValueConverter Interface\n[ https://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter(v=vs.110).aspx]( https://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter(v=vs.110).aspx)  \n\n- Windows.UI.Xaml.Data.IValueConverter interface:\n[ https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.data.ivalueconverter]( https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.data.ivalueconverter)  \n\n### License\nValueConverters.NET is Copyright \u0026copy; 2021 [Thomas Galliker]( https://ch.linkedin.com/in/thomasgalliker). Free for non-commercial use. For commercial use please contact the author. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femako%2Fvalueconverters.avalonia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femako%2Fvalueconverters.avalonia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femako%2Fvalueconverters.avalonia/lists"}