mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 19:25:01 +00:00
Add menu to WPF example
Can now easily open binding test example TODO: Import tests from cefclient example
This commit is contained in:
@@ -122,6 +122,7 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Controls\CefSharpCommands.cs" />
|
||||
<Compile Include="Controls\NonReloadingTabControl.cs" />
|
||||
<Compile Include="Handlers\GeolocationHandler.cs" />
|
||||
<Compile Include="Handlers\MenuHandler.cs" />
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright © 2010-2015 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace CefSharp.Wpf.Example.Controls
|
||||
{
|
||||
public static class CefSharpCommands
|
||||
{
|
||||
public static RoutedUICommand Exit = new RoutedUICommand("Exit", "Exit", typeof(CefSharpCommands));
|
||||
public static RoutedUICommand OpenTabBindingTest = new RoutedUICommand("OpenTabBindingTest", "OpenTabBindingTest", typeof(CefSharpCommands));
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,17 @@
|
||||
<KeyBinding Key="T" Modifiers="Control" Command="New"/>
|
||||
<KeyBinding Key="W" Modifiers="Control" Command="Close"/>
|
||||
</Window.InputBindings>
|
||||
<Grid>
|
||||
<DockPanel>
|
||||
<Menu DockPanel.Dock="Top">
|
||||
<MenuItem Header="_File">
|
||||
<MenuItem Header="_New Tab" Command="New"/>
|
||||
<MenuItem Header="_Close Tab" Command="Close"/>
|
||||
<MenuItem Header="_Exit" Command="controls:CefSharpCommands.Exit"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Tests">
|
||||
<MenuItem Header="_Binding Test" Command="controls:CefSharpCommands.OpenTabBindingTest"/>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<controls:NonReloadingTabControl x:Name="TabControl"
|
||||
Margin="0,5,0,0"
|
||||
ItemsSource="{Binding BrowserTabs, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
@@ -37,5 +47,5 @@
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</controls:NonReloadingTabControl>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using CefSharp.Example;
|
||||
using CefSharp.Wpf.Example.Controls;
|
||||
using CefSharp.Wpf.Example.ViewModels;
|
||||
|
||||
namespace CefSharp.Wpf.Example
|
||||
@@ -27,6 +28,9 @@ namespace CefSharp.Wpf.Example
|
||||
CommandBindings.Add(new CommandBinding(ApplicationCommands.New, OpenNewTab));
|
||||
CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, CloseTab));
|
||||
|
||||
CommandBindings.Add(new CommandBinding(CefSharpCommands.Exit, Exit));
|
||||
CommandBindings.Add(new CommandBinding(CefSharpCommands.OpenTabBindingTest, OpenTabBindingTest));
|
||||
|
||||
Loaded += MainWindowLoaded;
|
||||
|
||||
var bitness = Environment.Is64BitProcess ? "x64" : "x86";
|
||||
@@ -74,5 +78,17 @@ namespace CefSharp.Wpf.Example
|
||||
{
|
||||
BrowserTabs.Add(new BrowserTabViewModel(url) { ShowSidebar = showSideBar });
|
||||
}
|
||||
|
||||
private void OpenTabBindingTest(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
CreateNewTab(CefExample.BindingTestUrl, true);
|
||||
|
||||
TabControl.SelectedIndex = TabControl.Items.Count - 1;
|
||||
}
|
||||
|
||||
private void Exit(object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user