❔ Avalonia ComboBox SelectedValuePath

<ComboBox SelectedValue="{Binding Path=SomeValue, Mode=TwoWay}" SelectedValuePath="Tag">
<ComboBoxItem Tag="x">A</ComboBoxItem>
<ComboBoxItem Tag="y">B</ComboBoxItem>
</ComboBox>
<ComboBox SelectedValue="{Binding Path=SomeValue, Mode=TwoWay}" SelectedValuePath="Tag">
<ComboBoxItem Tag="x">A</ComboBoxItem>
<ComboBoxItem Tag="y">B</ComboBoxItem>
</ComboBox>
Is there a way to do this in Avalonia?
4 Replies
Aurumaker72
Aurumaker72OP2y ago
<ComboBox SelectedValue="{Binding Theme, Mode=TwoWay}">
<ComboBox.Items>
<x:String>Light</x:String>
<x:String>Dark</x:String>
</ComboBox.Items>
</ComboBox>
<ComboBox SelectedValue="{Binding Theme, Mode=TwoWay}">
<ComboBox.Items>
<x:String>Light</x:String>
<x:String>Dark</x:String>
</ComboBox.Items>
</ComboBox>
I came up with this, but it's not localizable In WPF, you'd just do the following:
<ComboBox SelectedValue="{Binding Path=Theme, Mode=TwoWay}" SelectedValuePath="Tag">
<ComboBoxItem Tag="Light" Content="{LocalizedBinding Light}" />
<ComboBoxItem Tag="Dark" Content="{LocalizedBinding Dark}" />
</ComboBox>
<ComboBox SelectedValue="{Binding Path=Theme, Mode=TwoWay}" SelectedValuePath="Tag">
<ComboBoxItem Tag="Light" Content="{LocalizedBinding Light}" />
<ComboBoxItem Tag="Dark" Content="{LocalizedBinding Dark}" />
</ComboBox>
Honza K.
Honza K.2y ago
I've used a DynamicResource with resource dictionaries for each locale, so it can be changed in runtime without the need of restarting the app or you can you this https://dev.to/ingvarx/localization-in-avaloniaui-2mdm (https://github.com/IngvarX/Camelot/blob/master/src/Camelot/Services/Implementations/LanguageManager.cs)
DEV Community
Localization in AvaloniaUI
Hey there! This time I gonna explain how to add localization support in your AvaloniaUI app. As...
GitHub
Camelot/LanguageManager.cs at master · IngvarX/Camelot
Camelot is cross-platform file manager written in C# - Camelot/LanguageManager.cs at master · IngvarX/Camelot
Aurumaker72
Aurumaker72OP2y ago
Thank you, but that's not what I'm looking for I already implemented a working localization system, the issue is as described in the thread title.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server