mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Update ReactiveUI Example
This commit is contained in:
24
ReactiveExample/ViewExtensions.cs
Normal file
24
ReactiveExample/ViewExtensions.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using Terminal.Gui;
|
||||
|
||||
namespace ReactiveExample;
|
||||
public static class ViewExtensions
|
||||
{
|
||||
public static (Window MainView, TOut LastControl) AddControl<TOut> (this Window view, Action<TOut> action)
|
||||
where TOut : View, new()
|
||||
{
|
||||
TOut result = new ();
|
||||
action (result);
|
||||
view.Add (result);
|
||||
return (view, result);
|
||||
}
|
||||
|
||||
public static (Window MainView, TOut LastControl) AddControlAfter<TOut> (this (Window MainView, View LastControl) view, Action<View, TOut> action)
|
||||
where TOut : View, new()
|
||||
{
|
||||
TOut result = new ();
|
||||
action (view.LastControl, result);
|
||||
view.MainView.Add (result);
|
||||
return (view.MainView, result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user