문서의 이전 판입니다!
1
Quick Start in WPF
cefsharp를 wpf 환경에서 사용하는 예제 코드는 아래와 같다.
<Window x:Class="semiweb.MainWindow" 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" xmlns:local="clr-namespace:semiweb" xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" mc:Ignorable="d" Title="SemiWeb" Height="786" Width="1024"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid> <Grid.Resources> <Style TargetType="{x:Type Button}"> <Setter Property="Margin" Value="2,5" /> </Style> <Style TargetType="{x:Type TextBox}"> <Setter Property="Margin" Value="2,5" /> </Style> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <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" /> <TextBox x:Name="txtBoxAddress" Text="{Binding Address, ElementName=Browser, FallbackValue=www.google.com}" Grid.Column="2" FontSize="12" BorderBrush="Gray" BorderThickness="1" /> <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" /> </Grid> <Border Grid.Row="1" BorderBrush="Gray" BorderThickness="0,1"> <cefSharp:ChromiumWebBrowser x:Name="Browser" Address="{Binding Text, ElementName=txtBoxAddress}"></cefSharp:ChromiumWebBrowser> </Border> <StatusBar Grid.Row="2" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"> <StatusBar.ItemsPanel> <ItemsPanelTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> </Grid> </ItemsPanelTemplate> </StatusBar.ItemsPanel> <StatusBarItem> <ProgressBar HorizontalAlignment="Right" IsIndeterminate="{Binding IsLoading, ElementName=Browser}" Width="100" Height="16" Margin="3" /> </StatusBarItem> <Separator Grid.Column="1" /> <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"> Status is Well done. </TextBlock> </StatusBarItem> </StatusBar> </Grid> </Window>
“'`–