File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
AsyncImageLoader.Avalonia Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -14,23 +14,25 @@ static ImageLoader() {
14
14
. Subscribe ( args => OnSourceChanged ( ( Image ) args . Sender , args . NewValue . Value ) ) ;
15
15
}
16
16
17
- private static async void OnSourceChanged ( Image sender , string url ) {
17
+ private static async void OnSourceChanged ( Image sender , string ? url ) {
18
18
SetIsLoading ( sender , true ) ;
19
-
20
- var bitmap = await AsyncImageLoader . ProvideImageAsync ( url ) ;
19
+
20
+ var bitmap = url == null
21
+ ? null
22
+ : await AsyncImageLoader . ProvideImageAsync ( url ) ;
21
23
if ( GetSource ( sender ) != url ) return ;
22
24
sender . Source = bitmap ;
23
-
25
+
24
26
SetIsLoading ( sender , false ) ;
25
27
}
26
28
27
- public static readonly AttachedProperty < string > SourceProperty = AvaloniaProperty . RegisterAttached < Image , string > ( "Source" , typeof ( ImageLoader ) ) ;
29
+ public static readonly AttachedProperty < string ? > SourceProperty = AvaloniaProperty . RegisterAttached < Image , string ? > ( "Source" , typeof ( ImageLoader ) ) ;
28
30
29
- public static string GetSource ( Image element ) {
31
+ public static string ? GetSource ( Image element ) {
30
32
return element . GetValue ( SourceProperty ) ;
31
33
}
32
34
33
- public static void SetSource ( Image element , string value ) {
35
+ public static void SetSource ( Image element , string ? value ) {
34
36
element . SetValue ( SourceProperty , value ) ;
35
37
}
36
38
You can’t perform that action at this time.
0 commit comments