Skip to content

Instantly share code, notes, and snippets.

View XDarinor's full-sized avatar

Alessandro Morvillo XDarinor

View GitHub Profile
@XDarinor
XDarinor / NavigationItemDestination.cs
Created October 8, 2025 10:37
NavigationItemDestination XAML extension for WinUI3
public class NavigationItemDestination
{
#region Fields
public static readonly DependencyProperty ViewModelTypeProperty = DependencyProperty.RegisterAttached("ViewModelType",
typeof(Type),
typeof(NavigationItemDestination),
new PropertyMetadata(null));
#endregion
@XDarinor
XDarinor / NavigationService.cs
Created April 4, 2025 10:28
Simple navigation provider for WinUI3
public interface INavigationParameters
{
#region Properties
Type NavigationPageViewModel { get; }
object? OptionalTransitionData { get; }
object? Parameter { get; }
bool ForceNavigation
{
@XDarinor
XDarinor / TextBoxUpdateSourceOnTextChangedBehavior.cs
Last active November 7, 2024 14:40
A WinUI 3 XAML Behavior for TextBox that I've coded for a little project of mine. Allows to fine control the update of a databinding for the Text property of a TextBox. Can be edited for other Text controls or XAML frameworks as well.
public class TextBoxUpdateSourceOnTextChangedBehavior
: Behavior<TextBox>
{
#region Properties
public static readonly DependencyProperty UpdateSourceOnTextChangedProperty = DependencyProperty.Register(nameof(UpdateSourceOnTextChanged),
typeof(bool),
typeof(TextBoxUpdateSourceOnTextChangedBehavior),
new PropertyMetadata(false));
@XDarinor
XDarinor / CommonNuGetPackages.ps1
Created November 3, 2024 18:08
Powershell commands for installing common NuGet packages
# Useful pckages for all kind of projects
Install-Package Microsoft.Extensions.DependencyInjection
Install-Package Microsoft.Extensions.Logging
Install-Package Microsoft.Extensions.Logging.Debug
Install-Package Microsoft.Extensions.Logging.Configuration
Install-Package Microsoft.Extensions.Configuration
Install-Package Microsoft.Extensions.Configuration.Json
Install-Package Microsoft.Extensions.Configuration.Binder
@XDarinor
XDarinor / ByteArrayToImageConverter.cs
Created November 2, 2024 16:03
A XAML Converter used to convert a byte array in a viewmodel to an ImageSource and back.
public class ByteArrayToImageConverter
: IValueConverter
{
#region Methods
public object? Convert(object? value, Type? targetType, object? parameter, string? language)
{
if (value is byte[] bytes && bytes.Length > 0)
{
return LoadImage(bytes);
@XDarinor
XDarinor / EnumerableCountToBoolConverter.cs
Last active November 2, 2024 16:04
A XAML converter that signals if an IEnumerable instance is empty or not.
public class EnumerableCountToBoolConverter
: IValueConverter
{
#region Methods
public object? Convert(object? value, Type targetType, object? parameter, string? language)
{
if (value is IEnumerable enumerable)
{
foreach (var item in enumerable)
// Return true if theres at least one element in the collection