Reputation: 518
I have the following code, what i`m trying to do is to replace a user control's content with a new Grid, that grid then will host a webviewer. If i test the following code the webviewer is not visible.
Content = ContentGrid;
ContentGrid.VerticalAlignment = VerticalAlignment.Stretch;
ContentGrid.HorizontalAlignment = HorizontalAlignment.Stretch;
var rectangle = new Rectangle();
rectangle.Height = 300;
rectangle.Width = 300;
rectangle.Fill = new SolidColorBrush(Colors.Red);
WebView.Name = "CevaSmecher";
WebView.VerticalAlignment = VerticalAlignment.Stretch;
WebView.HorizontalAlignment = HorizontalAlignment.Stretch;
WebView.Height = 300;
WebView.Height = 300;
WebView.Visibility = Visibility.Visible;
WebView.DefaultBackgroundColor = Colors.Red;
ContentGrid.Name = "SmecherieRoute";
ContentGrid.Background = new SolidColorBrush(Colors.BlueViolet);
ContentGrid.Children.Insert(0, WebView);
Then i replace the last line with this one and rectangle is visible.
ContentGrid.Children.Insert(0, rectangle);
Upvotes: 0
Views: 169
Reputation: 323
I had the same issue. My problem was that, in the UserControl the CacheMode was set to BitmapCache.
CacheMode = new BitmapCache();
After I removed this line, the WebView appeared.
Upvotes: 1