4 changed files with 17 additions and 43 deletions
@ -1,52 +1,29 @@ |
|||||
using System; |
using System.Windows; |
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Text; |
|
||||
using System.Threading.Tasks; |
|
||||
using System.Windows.Controls; |
|
||||
using System.Windows.Data; |
|
||||
using System.Windows.Documents; |
|
||||
using System.Windows.Input; |
|
||||
using System.Windows.Media; |
|
||||
using System.Windows.Media.Imaging; |
|
||||
using System.Windows.Navigation; |
|
||||
using System.Windows.Shapes; |
|
||||
using Avalonia; |
using Avalonia; |
||||
using Avalonia.Controls; |
using Avalonia.Controls; |
||||
using Avalonia.Rendering; |
|
||||
using Avalonia.VisualTree; |
|
||||
using ControlCatalog; |
using ControlCatalog; |
||||
using Window = System.Windows.Window; |
|
||||
|
|
||||
namespace WindowsInteropTest |
namespace WindowsInteropTest |
||||
{ |
{ |
||||
/// <summary>
|
public partial class EmbedToWpfDemo |
||||
/// Interaction logic for EmbedToWpfDemo.xaml
|
|
||||
/// </summary>
|
|
||||
public partial class EmbedToWpfDemo : Window |
|
||||
{ |
{ |
||||
private IRenderer _renderer; |
|
||||
public EmbedToWpfDemo() |
public EmbedToWpfDemo() |
||||
{ |
{ |
||||
InitializeComponent(); |
InitializeComponent(); |
||||
var view = new MainView(); |
Host.Content = new MainView(); |
||||
Host.Content = view; |
|
||||
var tl = (TopLevel)view.GetVisualRoot(); |
var btn = (Button) RightBtn.Content!; |
||||
tl.AttachDevTools(); |
|
||||
_renderer = tl.Renderer; |
|
||||
_renderer.Start(); |
|
||||
var btn = (Avalonia.Controls.Button) RightBtn.Content; |
|
||||
btn.Click += delegate |
btn.Click += delegate |
||||
{ |
{ |
||||
btn.Content += "!"; |
btn.Content += "!"; |
||||
}; |
}; |
||||
|
|
||||
|
Loaded += OnLoaded; |
||||
} |
} |
||||
|
|
||||
protected override void OnClosed(EventArgs e) |
private void OnLoaded(object sender, RoutedEventArgs e) |
||||
{ |
{ |
||||
_renderer.Stop(); |
TopLevel.GetTopLevel((MainView)Host.Content)!.AttachDevTools(); |
||||
base.OnClosed(e); |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue