Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion PhotonUI/Controls/Content/TextBlockSelectable.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CommunityToolkit.Mvvm.ComponentModel;
using PhotonUI.Events;
using PhotonUI.Events.Platform;
using PhotonUI.Extensions;
using PhotonUI.Interfaces.Services;
using PhotonUI.Models;
Expand Down
1 change: 0 additions & 1 deletion PhotonUI/Controls/Input/TextInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using PhotonUI.Models.Properties;
using SDL3;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Input;

Expand Down
25 changes: 25 additions & 0 deletions PhotonUI/ViewModels/ViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using CommunityToolkit.Mvvm.ComponentModel;
using PhotonUI.Controls;
using PhotonUI.Events;
using PhotonUI.Extensions;
using PhotonUI.Interfaces.Services;

namespace PhotonUI.ViewModels
{
public abstract partial class ViewModelBase(IServiceProvider serviceProvider, IBindingService bindingService)
: ObservableObject
{
protected readonly IServiceProvider ServiceProvider = serviceProvider;
protected readonly IBindingService BindingService = bindingService;

public virtual void OnEvent(Window window, PlatformEventArgs e) { }

public virtual T Create<T>()
where T : class => DependencyInjectionExtensions.Create<T>(this.ServiceProvider);

public virtual void Bind(Control target, string targetProperty, object source, string sourceProperty, bool twoWay = false)
=> this.BindingService.Bind(target, targetProperty, source, sourceProperty, twoWay);
public void Unbind(Control target, string targetProperty)
=> this.BindingService.Unbind(target, targetProperty);
}
}