Create shared boot animation in mvvm

I have an mvvm application that retrieves a lot of data from a remote server. I want to add animation during data loading which is the best way to do this.

+3
source share
2 answers

One way is to have a property in the view model named IsLoadingData. You can then bind it to the Visibility property of the control that hosts the animation using the BooleanToVisibilityConverter.

Visibility={Binding 
    Path=IsLoadingData, 
    Converter={StaticResource BooleanToVisibilityConverter}}

This control can then use the ControlTemplate to launch the storyboard containing the animation when the VisibilityProperty parameter is set to true.

<ControlTemplate.Triggers>
    <Trigger Property="IsVisible" Value="True">
        <Trigger.EnterActions>
            <BeginStoryboard 
                x:Name="Storyboard0" 
                Storyboard="{StaticResource Animation0}" 
                />
        </Trigger.EnterActions>
    </Trigger>
</ControlTemplate.Triggers>

. , .

+2

, DataTemplate , . , , DataTemplate . IsLoaded/IsRefreshed. DataTrigger DataTemplate, ( ), IsLoaded VM, , ( ), .

, - http://jobijoy.blogspot.com/2009/07/easy-way-to-update-all-ui-property.html, , , - Raise NotifypropertyChanged , PropertyChangedEventArgs Datatemplate.

+1

Source: https://habr.com/ru/post/1713537/