Skip to content

Releases: roubachof/Sharpnado.TaskLoaderView

TemplatedTaskLoader Events Now Include Actual View

24 Oct 02:31

Choose a tag to compare

Release Notes

Version 2.6.3 (2025-10-24)

Enhanced Features

TemplatedTaskLoader Events Now Include Actual View

The TemplatedTaskLoader events have been significantly enhanced! All four events now pass the actual view created from the ControlTemplate via the new ControlTemplateLoadedEventArgs class:

  • ResultControlTemplateLoaded - Now includes the result view in e.View
  • LoadingControlTemplateLoaded - Now includes the loading view in e.View
  • ErrorControlTemplateLoaded - Now includes the error view in e.View
  • EmptyControlTemplateLoaded - Now includes the empty view in e.View

New GetTemplateChild Method

Added GetTemplateChild(string name) method to easily retrieve named children from within the control template.

Usage Examples

Accessing the view from events:

myTemplatedTaskLoader.LoadingControlTemplateLoaded += (sender, e) => 
{
    if (e.View is ActivityIndicator indicator)
    {
        // Directly manipulate the loading indicator
        indicator.Color = Colors.Red;
        Console.WriteLine($"Loading indicator is running: {indicator.IsRunning}");
    }
};

myTemplatedTaskLoader.ResultControlTemplateLoaded += (sender, e) => 
{
    if (e.View is Grid grid)
    {
        // Access and modify the result view
        Console.WriteLine($"Result grid has {grid.Children.Count} children");
        // Add custom behavior, animations, etc.
    }
};

Using GetTemplateChild to find named elements:

<tlv:TemplatedTaskLoader.LoadingControlTemplate>
    <ControlTemplate>
        <ActivityIndicator x:Name="MyLoadingIndicator" 
                          Color="{StaticResource AccentColor}" />
    </ControlTemplate>
</tlv:TemplatedTaskLoader.LoadingControlTemplate>
// Find and manipulate named children
var indicator = myTemplatedTaskLoader.GetTemplateChild("MyLoadingIndicator") as ActivityIndicator;
if (indicator != null)
{
    indicator.Scale = 1.5;
}

Technical Implementation

This enhancement uses reflection to access MAUI's internal TemplateRoot property, which contains the actual view created from the ControlTemplate. The implementation is robust and includes proper error handling for future MAUI version compatibility.

Benefits

  • Full view access: Directly manipulate views created from templates
  • Custom animations: Add or trigger animations when states change
  • Dynamic styling: Change appearance based on runtime conditions
  • Advanced debugging: Inspect and validate template structure
  • Named element access: Easily find specific controls within templates

TemplatedTaskLoader Events

23 Oct 23:49

Choose a tag to compare

Version 2.6.2 (2025-10-24)

New Features

TemplatedTaskLoader Events

Added four new events to the TemplatedTaskLoader class that are raised when each corresponding control template is loaded:

  • ResultControlTemplateLoaded - Fired when the result control template is displayed
  • LoadingControlTemplateLoaded - Fired when the loading control template is displayed
  • ErrorControlTemplateLoaded - Fired when the error control template is displayed
  • EmptyControlTemplateLoaded - Fired when the empty control template is displayed

Usage Example

// In your code-behind
myTemplatedTaskLoader.LoadingControlTemplateLoaded += (sender, e) => 
{
    // React to loading state being displayed
    Debug.WriteLine("Loading template is now visible");
};

myTemplatedTaskLoader.ResultControlTemplateLoaded += (sender, e) => 
{
    // React to result state being displayed
    Debug.WriteLine("Result template is now visible");
};

myTemplatedTaskLoader.ErrorControlTemplateLoaded += (sender, e) => 
{
    // React to error state being displayed
    Debug.WriteLine("Error template is now visible");
};

myTemplatedTaskLoader.EmptyControlTemplateLoaded += (sender, e) => 
{
    // React to empty state being displayed
    Debug.WriteLine("Empty template is now visible");
};

Benefits

These events enable you to:

  • Track state transitions for analytics or logging
  • Trigger custom animations when states change
  • Implement custom behaviors based on the loading state
  • Simplify testing by monitoring state changes

Version 2.6.1 (Previous Release)

Bug Fixes

  • Fixed the insertion of the loading states view that could cause an index out of range exception.

Fix the insertion of the loading states view that could cause an index out of range exception.

09 Sep 14:56

Choose a tag to compare

Upgrade to .net9

11 Aug 17:23

Choose a tag to compare

it's in the title dummy !
Plus snackbar is now a border and not a frame

Use TemplatedTaskLoader (implemented with ControlTemplate) with Snackbar

23 Jun 15:22

Choose a tag to compare

Builder for the CompositeTaskLoader

If you want to bind on the same snackbar loaders, and commands, there is now a nice builder.
With this change you can now use a TemplatedTaskLoader and a snackbar and making them play nicely together.

CompositeNotifier = CompositeTaskLoaderNotifier.ForCommands()
                .WithLoaders(Loader)
                .WithCommands(BuyGameCommand, PlayTheGameCommand)
                .Build();

And you bind the ShowLastError
on your snackbar:

<tlv:Snackbar Grid.Row="1"
                          Margin="15"
                          VerticalOptions="End"
                          BackgroundColor="White"
                          FontFamily="FontAtariSt"
                          IsVisible="{Binding CompositeNotifier.ShowLastError, Mode=TwoWay}"
                          Text="{Binding CompositeNotifier.LastError, Converter={StaticResource ExceptionToErrorMessageConverter}}"
                          TextColor="{StaticResource TextPrimaryColor}"
                          TextHorizontalOptions="Start" />
  • Fix for the timed visibility when the snackbar (or a ITimedVisibilityText implementation) text is changing.

Fix behavior of TaskLoaderNotifier when two tasks are loaded sequentially

23 Jun 08:44

Choose a tag to compare

Semantic change

As of 2.4.0, considering the following scenario:

  1. You start to load a task using the Load command
  2. Then a second load is asked by calling the Load command while the first load hasn't finished yet

Then the result of the first load will be discarded and the second load will take priority.

BREAKING CHANGES

The task source given to TaskLoaderNotifier is now a Func<bool, Task> (or a Func<bool, Task<T>>) instead of a Func<Task>.
You can simply change your calls from Loader.Load(() => InitializeAsync()) to Loader.Load(_ => InitializeAsync())
The boolean passed now to your task source is a boolean indicating if the notifier is refreshing.
You can use it for invalidating your cache for example.

Loader.Load(LoadItems);

public Task LoadItems(bool isRefreshing)
{
    if (isRefreshing || !_cache.ContainsItems())
    {
         _cache.InvalidateItems();
         var items = _httpService.GetItems()
         _cache.PutItems(items);
         return items;
    }

    return _cache.GetItems();
}

When the RefreshCommand will be called, it will pass automatically the isRefreshing boolean set to true to your task source.

Fixes

  • Fix Snackbar BackgroundColor and CompositeLoader behavior.

Snackbar with Composite Commands

09 Mar 15:19

Choose a tag to compare

SourceLink support

02 Aug 10:41

Choose a tag to compare

v2.1.1

enable source link

DataTemplate support

30 Jul 16:27
5046359

Choose a tag to compare

DataTemplate support

You can now add your customs views as View or DataTemplate.
If you choose the latest option, you can now specify your custom views in a ResourceDictionary and set them in your TaskLoaderView style.

Fixes

  • #1 Disable EmptyView in the TaskLoaderNotifier thanks to the disableEmptyView constructor parameter
  • #2 Provide set access to RefreshCommand

Expose TaskMonitor inner object

23 Jul 08:48

Choose a tag to compare

  • Expose the TaskMonitor object to be able to await it and chain tasks.
  • Fixes a bad implementation of TaskLoaderCommand
  • Fixes crash when setting implicit style