C
C#10mo ago
d10x

how do i bind a skiasharp animation based on a string in maui using the ObservableObject class

i'm creating a weather app and i get as a response from the api the status of the current weather. since it's a string i could store it in a public string currentWeather with the [ObservableProperty] annotation. since i have animations stored in my Resources/Raw folder, i'm trying to bind from the xaml code the SKLottieView to the CurrentWeather property that was created by the [ObservableProperty] which is placed in the viewmodel. the problem is, it does take the space in my application through the HeightRequest and WidthRequest, but it's not visible.
XAML code
<skia:SKLottieView
Source="{Binding CurrentWeather}"
RepeatCount="-1"
HeightRequest="300"
WidthRequest="200"
HorizontalOptions="Center" >
</skia:SKLottieView>
XAML code
<skia:SKLottieView
Source="{Binding CurrentWeather}"
RepeatCount="-1"
HeightRequest="300"
WidthRequest="200"
HorizontalOptions="Center" >
</skia:SKLottieView>
ViewModel code
[ObservableProperty]
public string currentWeather;

public YourCurrentLocationForecast(WeatherService weatherService, IConnectivity connectivity, IGeolocation geolocation)
{
this.weatherService = weatherService;
this.connectivity = connectivity;
this.geolocation = geolocation;
title = "Weather";
CurrentWeather = "night_raining.json";
TestingTheDailyStatMethod();
}
ViewModel code
[ObservableProperty]
public string currentWeather;

public YourCurrentLocationForecast(WeatherService weatherService, IConnectivity connectivity, IGeolocation geolocation)
{
this.weatherService = weatherService;
this.connectivity = connectivity;
this.geolocation = geolocation;
title = "Weather";
CurrentWeather = "night_raining.json";
TestingTheDailyStatMethod();
}
as you've noticed, i tried first to hardcode the CurrentWeather property just to check whether it would work before i create a converter class to convert the received status string from the api into the json animation name. i wanted to see if it works. do you have any advice on how i should bind in the xaml code, maybe i'm not doing something right.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server