Open ricavir11 opened 3 weeks ago
Icon is not displayed when a binding is applied with MVVM.
ViewModel example :
private FontAwesomeSolidIcons _myIcon; public FontAwesomeSolidIcons MyIcon { get => _myIcon; set { _myIcon = value; RaisePropertyChanged(() => MyIcon); } } public async Task PageAppearingAsync() { MyIcon = FontAwesomeSolidIcons.AddressBook; }
Related view component (Button)
<Button Command="{Binding SearchAddressCommand}" Text="{mi:FontAwesomeSolid BindingContext={x:Reference HomeViewPage}, Icon={Binding MyIcon}, IconColor={DynamicResource PrimaryColor}, IconSize=25}" />
Would mind sharing a repro sample on this, in our testing binding just works fine.
Yes I will try to provide it soon. In my current project I'm using MVVM Helpers library but I will provide an example without it. Nevertheless, it would be interesting to provide a simple sample with MVVM bindings
Hey i had the same problem. I fixed it by adding the MVVM BindingContext to the XAML and reference it by name instead of adding it in the code behind.
Example:
<ContentPage ...>
<ContentPage.BindingContext>
<local:MainViewModel x:Name="MainViewModelName" />
</ContentPage.BindingContext>
...
<mi:MauiIcon Icon="{mi:FontAwesomeSolid Icon={Binding MyIcon},BindingContext={x:Reference MainViewModelName}}" />
...
</ContentPage>
We have made a some improvements to overall binding support with v4 and that makes this no longer issue at all.
Additionally, we are final stage of the release. Stay tuned for v4
Icon is not displayed when a binding is applied with MVVM.
ViewModel example :
Related view component (Button)