mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 03:32:37 +00:00
@@ -9,7 +9,7 @@
|
||||
xmlns:hwndhost="clr-namespace:CefSharp.Wpf.HwndHost;assembly=CefSharp.Wpf.HwndHost"
|
||||
FocusManager.FocusedElement="{Binding ElementName=Browser}"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="768" Width="1024">
|
||||
Title="CefSharp.Wpf.HwndHost.Example - MainWindow" Height="768" Width="1024">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<Window x:Class="CefSharp.Wpf.HwndHost.Example.TabbedMainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Title="CefSharp.Wpf.HwndHost.Example - TabbedMainWindow" Height="450" Width="800">
|
||||
<Grid>
|
||||
<Button Height="20" VerticalAlignment="Top" Content="New tab" Click="OnNewTabButtonClick"/>
|
||||
<Button Height="20" Margin="0,20,0,0" VerticalAlignment="Top" Content="Close current tab" Click="OnCloseTabButtonClick"/>
|
||||
<TabControl x:Name="Tabs" Margin="0,40,0,0"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace CefSharp.Wpf.HwndHost.Example
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for TabbedMainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class TabbedMainWindow : Window
|
||||
{
|
||||
public TabbedMainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
NewTab();
|
||||
NewTab();
|
||||
NewTab();
|
||||
}
|
||||
|
||||
private void NewTab()
|
||||
{
|
||||
var browser = new ChromiumWebBrowser("https://example.com/");
|
||||
browser.Address = "https://example.com/";
|
||||
Tabs.Items.Add(new TabItem { Header = "Tab", Content = browser });
|
||||
}
|
||||
|
||||
private void OnNewTabButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
NewTab();
|
||||
}
|
||||
|
||||
private void OnCloseTabButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var Tab = (TabItem)Tabs.Items[Tabs.SelectedIndex];
|
||||
var browser = (ChromiumWebBrowser)Tab.Content;
|
||||
Tab.Content = null;
|
||||
browser.Dispose();
|
||||
Tabs.Items.Remove(Tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user