Releases: roubachof/Sharpnado.TaskLoaderView
TemplatedTaskLoader Events Now Include Actual View
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 ine.ViewLoadingControlTemplateLoaded- Now includes the loading view ine.ViewErrorControlTemplateLoaded- Now includes the error view ine.ViewEmptyControlTemplateLoaded- Now includes the empty view ine.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
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 displayedLoadingControlTemplateLoaded- Fired when the loading control template is displayedErrorControlTemplateLoaded- Fired when the error control template is displayedEmptyControlTemplateLoaded- 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.
v2.6.1 chore: increase version number
Upgrade to .net9
it's in the title dummy !
Plus snackbar is now a border and not a frame
Use TemplatedTaskLoader (implemented with ControlTemplate) with Snackbar
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
Semantic change
As of 2.4.0, considering the following scenario:
- You start to load a task using the Load command
- 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
BackgroundColorandCompositeLoaderbehavior.
Snackbar with Composite Commands
Bind MVVM Async Commands to Snackar and Loading dialog.
SourceLink support
v2.1.1 enable source link
DataTemplate support
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
Expose TaskMonitor inner object
- Expose the
TaskMonitorobject to be able to await it and chain tasks. - Fixes a bad implementation of
TaskLoaderCommand - Fixes crash when setting implicit style