Merge branch 'master' of https://github.com/nikhilagrawaldotnet/CefSharp.MinimalExample into cefsharp/63
This commit is contained in:
commit
a923fe4d83
@ -6,5 +6,6 @@
|
|||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<converter:TitleConverter x:Key="TitleConverter"/>
|
<converter:TitleConverter x:Key="TitleConverter"/>
|
||||||
<converter:EnvironmentConverter x:Key="EnvironmentConverter" />
|
<converter:EnvironmentConverter x:Key="EnvironmentConverter" />
|
||||||
|
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</Application>
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
using System.Windows.Interactivity;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace CefSharp.MinimalExample.Wpf.Behaviours
|
||||||
|
{
|
||||||
|
public class TextBoxBindingUpdateOnEnterBehaviour : Behavior<TextBox>
|
||||||
|
{
|
||||||
|
protected override void OnAttached()
|
||||||
|
{
|
||||||
|
AssociatedObject.KeyDown += OnTextBoxKeyDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDetaching()
|
||||||
|
{
|
||||||
|
AssociatedObject.KeyDown -= OnTextBoxKeyDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTextBoxKeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Enter)
|
||||||
|
{
|
||||||
|
var txtBox = sender as TextBox;
|
||||||
|
txtBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -105,6 +105,7 @@
|
|||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Behaviours\HoverLinkBehaviour.cs" />
|
<Compile Include="Behaviours\HoverLinkBehaviour.cs" />
|
||||||
|
<Compile Include="Behaviours\TextBoxBindingUpdateOnEnterBehaviour.cs" />
|
||||||
<Compile Include="Converter\EnvironmentConverter.cs" />
|
<Compile Include="Converter\EnvironmentConverter.cs" />
|
||||||
<Compile Include="Converter\TitleConverter.cs" />
|
<Compile Include="Converter\TitleConverter.cs" />
|
||||||
<Compile Include="MainWindow.xaml.cs">
|
<Compile Include="MainWindow.xaml.cs">
|
||||||
|
@ -6,15 +6,14 @@ namespace CefSharp.MinimalExample.Wpf.Converter
|
|||||||
{
|
{
|
||||||
public class TitleConverter : IValueConverter
|
public class TitleConverter : IValueConverter
|
||||||
{
|
{
|
||||||
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
|
|
||||||
return "CefSharp.MinimalExample.Wpf - " + (value ?? "No Title Specified");
|
return "CefSharp.MinimalExample.Wpf - " + (value ?? "No Title Specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
return System.Windows.Data.Binding.DoNothing;
|
return Binding.DoNothing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,25 +31,35 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Content="Back" Command="{Binding WebBrowser.BackCommand, ElementName=Browser}" Width="50"/>
|
<Button Content="Back" Command="{Binding WebBrowser.BackCommand, ElementName=Browser}" Width="50"/>
|
||||||
<Button Content="Forward" Command="{Binding WebBrowser.ForwardCommand, ElementName=Browser}" Grid.Column="1" Width="60"/>
|
<Button Content="Forward" Command="{Binding WebBrowser.ForwardCommand, ElementName=Browser}" Grid.Column="1" Width="60"/>
|
||||||
<TextBox x:Name="txtBoxAddress" Text="{Binding Address, ElementName=Browser, FallbackValue=www.google.com}" Grid.Column="2" FontSize="12" BorderBrush="Gray" BorderThickness="1" />
|
<TextBox x:Name="txtBoxAddress" Text="{Binding Address, ElementName=Browser, FallbackValue=www.google.com}" Grid.Column="2" FontSize="12" BorderBrush="Gray" BorderThickness="1">
|
||||||
|
<i:Interaction.Behaviors>
|
||||||
|
<behaviours:TextBoxBindingUpdateOnEnterBehaviour />
|
||||||
|
</i:Interaction.Behaviors>
|
||||||
|
</TextBox>
|
||||||
<Button Content="Print..." Command="{Binding WebBrowser.PrintCommand, ElementName=Browser}" Grid.Column="3" Width="50" />
|
<Button Content="Print..." Command="{Binding WebBrowser.PrintCommand, ElementName=Browser}" Grid.Column="3" Width="50" />
|
||||||
<Button Content="View source" Command="{Binding WebBrowser.ViewSourceCommand, ElementName=Browser}" Grid.Column="4" Width="75" />
|
<Button Content="View source" Command="{Binding WebBrowser.ViewSourceCommand, ElementName=Browser}" Grid.Column="4" Width="75" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Border Grid.Row="1" BorderBrush="Gray" BorderThickness="0,1">
|
<Border Grid.Row="1" BorderBrush="Gray" BorderThickness="0,1">
|
||||||
<wpf:ChromiumWebBrowser x:Name="Browser"
|
<wpf:ChromiumWebBrowser x:Name="Browser"
|
||||||
Address="{Binding Text, ElementName=txtBoxAddress}">
|
Address="www.google.com">
|
||||||
<i:Interaction.Behaviors>
|
<i:Interaction.Behaviors>
|
||||||
<behaviours:HoverLinkBehaviour x:Name="HoverLinkBehaviour"/>
|
<behaviours:HoverLinkBehaviour x:Name="HoverLinkBehaviour"/>
|
||||||
</i:Interaction.Behaviors>
|
</i:Interaction.Behaviors>
|
||||||
</wpf:ChromiumWebBrowser>
|
</wpf:ChromiumWebBrowser>
|
||||||
</Border>
|
</Border>
|
||||||
|
<ProgressBar IsIndeterminate="{Binding IsLoading, ElementName=Browser}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Width="Auto"
|
||||||
|
Grid.Row="1"
|
||||||
|
Height="2"
|
||||||
|
Visibility="{Binding IsLoading, ElementName=Browser, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||||
|
BorderThickness="0" />
|
||||||
<StatusBar Grid.Row="2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
|
<StatusBar Grid.Row="2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
|
||||||
<StatusBar.ItemsPanel>
|
<StatusBar.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
@ -57,19 +67,11 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</StatusBar.ItemsPanel>
|
</StatusBar.ItemsPanel>
|
||||||
<StatusBarItem>
|
<StatusBarItem Grid.Column="0">
|
||||||
<ProgressBar HorizontalAlignment="Right"
|
<TextBlock Text="{Binding HoverLink, ElementName=HoverLinkBehaviour}" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
|
||||||
IsIndeterminate="{Binding IsLoading, ElementName=Browser}"
|
|
||||||
Width="100"
|
|
||||||
Height="16"
|
|
||||||
Margin="3" />
|
|
||||||
</StatusBarItem>
|
</StatusBarItem>
|
||||||
<Separator Grid.Column="1" />
|
<Separator Grid.Column="1" />
|
||||||
<StatusBarItem Grid.Column="2">
|
<StatusBarItem Grid.Column="2">
|
||||||
<TextBlock Text="{Binding HoverLink, ElementName=HoverLinkBehaviour}" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
|
|
||||||
</StatusBarItem>
|
|
||||||
<Separator Grid.Column="3" />
|
|
||||||
<StatusBarItem Grid.Column="4">
|
|
||||||
<TextBlock HorizontalAlignment="Right" TextAlignment="Right" Grid.Column="3" VerticalAlignment="Center">
|
<TextBlock HorizontalAlignment="Right" TextAlignment="Right" Grid.Column="3" VerticalAlignment="Center">
|
||||||
Chromium: <Run Text="{Binding Source={x:Static cef:Cef.ChromiumVersion}, Mode=OneTime}" />, CEF: <Run Text="{Binding Source={x:Static cef:Cef.CefVersion}, Mode=OneTime}" />, CefSharp: <Run Text="{Binding Source={x:Static cef:Cef.CefSharpVersion}, Mode=OneTime}"/>, Environment: <Run Text="{Binding Converter={StaticResource EnvironmentConverter}, Mode=OneTime}"/>
|
Chromium: <Run Text="{Binding Source={x:Static cef:Cef.ChromiumVersion}, Mode=OneTime}" />, CEF: <Run Text="{Binding Source={x:Static cef:Cef.CefVersion}, Mode=OneTime}" />, CefSharp: <Run Text="{Binding Source={x:Static cef:Cef.CefSharpVersion}, Mode=OneTime}"/>, Environment: <Run Text="{Binding Converter={StaticResource EnvironmentConverter}, Mode=OneTime}"/>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
|
Loading…
Reference in New Issue
Block a user