I am using converters in my regular pages.
I add Currencies in the VM
public ObservableCollection<Currency> Currencies { get; set; } = new();
....
and then I use them in a picker like so:
<ContentPage.Resources>
<ResourceDictionary>
<model:CountryPickerConverter x:Key="CountryPickerConverter" />
<model:CurrencyPickerConverter x:Key="CurrencyPickerConverter" />
<toolkit:IsNotEqualConverter x:Key="IsNotEqualConverter" />
</ResourceDictionary>
</ContentPage.Resources>
and then
<Picker
Title="{x:Static res:AppRes.SelectCurrency}"
ItemsSource ="{Binding Currencies}"
ItemDisplayBinding ="{Binding ., Converter={StaticResource CurrencyPickerConverter}, Mode=TwoWay}"
..........
</Picker>
It works. But now I need to do the same thing in my toolkit:Popup object.
I am not able to write this section:
<toolkit:Popup.Resources>
<ResourceDictionary>
<model:CurrencyPickerConverter x:Key="CurrencyPickerConverter" />
</ResourceDictionary>
</toolkit:Popup>
or something similar.
I did not find any example on how to do this. What is the correct syntax for this, please ? Is it at all possible ?
Thank you. Alex
At the time of writing this, the <toolkit:Popup>
does not have a Resources-attribute (yet). You may want to use the Resources-attribute on the first child element (container) of the actual popup instead. In my case it was a <frame>
element:
<toolkit:Popup>
<Frame>
<Frame.Resources>
<model:CurrencyPickerConverter x:Key="CurrencyPickerConverter" />
</Frame.Resources>
</Frame>
</toolkit:Popup>
You can then use the converter for any controls within the <Frame>
element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With