Skip to content

Instantly share code, notes, and snippets.

View somapatrik's full-sized avatar

Patrik Šoma somapatrik

View GitHub Profile
@somapatrik
somapatrik / test.cs
Created September 26, 2023 07:06
Run WPF inside Forms
MyWpfProject.MainWindow mw = new MyWpfProject.MainWindow();
ElementHost.EnableModelessKeyboardInterop(mw);
mw.Show();
@somapatrik
somapatrik / PrimeViewModel.cs
Created November 20, 2023 10:15
ViewModel parent class
public class PrimeViewModel : INotifyPropertyChanged
{
protected bool SetProperty<T>(ref T backingStore, T value,
[CallerMemberName] string propertyName = "",
Action onChanged = null)
{
if (EqualityComparer<T>.Default.Equals(backingStore, value))
return false;
backingStore = value;
@somapatrik
somapatrik / RelayCommand.cs
Created November 20, 2023 10:20
WPF Relay Command
public class RelayCommand : ICommand
{
private Action<object> _execute;
private Func<object, bool> _canExecute;
public RelayCommand(Action<object> execute)
{
_execute = execute;
_canExecute = null;