I am using CefSharp in my WPF project. I'm adding the CefSharp.Wpf.WebView
class to my MainWindow.xaml like so:
_webView = new WebView(url, _settings);
My XAML layout looks like this:
<Window x:Class="WPFContainer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test Project" Height="400" Width="930" Initialized="OnWindowInit" StateChanged="OnWindowStateChanged" Closing="OnWindowClose">
<DockPanel Name="MainDockPanel" Height="400" Width="930">
<Grid VerticalAlignment="Top" HorizontalAlignment="Left" ShowGridLines="True" Name="mainGrid" >
<Grid.ColumnDefinitions>
<ColumnDefinition Name="col1" Width="600" />
<ColumnDefinition Name="col2" Width="330"/>
</Grid.ColumnDefinitions>
</Grid>
</DockPanel>
</Window>
If I remove the Grid
and add the webView
to the DockPanel
directly, it shows up just fine. But if I try to add the webView
to col1
in the Grid
, it doesn't display. It will display in the grid column if I specify a Width/Height, but HorizontalAlignment.Stretch
doesnt work and I need 100% width and height!
My code for adding the webView
to the Grid which doesn't work:
mainGrid.Children.Add(_webView);
Grid.SetColumn(_webView, 0);