Reputation: 1684
Here's my MainWindow XAML:
<Window x:Class="SomeApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="" Height="200" Width="400"
WindowStartupLocation="CenterScreen" Name="ViewData">
<DockPanel LastChildFill="True" Name="splMain" Background="{StaticResource GreyGradient}"></DockPanel>
</Window>
And here's the code for dynamic children creation:
private void ViewImgData(SubPod subPod)
{
var wb = new WebBrowser();
wb.Navigate(subPod.Image.Src);
DockPanel.SetDock(wb, Dock.Top);
((MainWindow)System.Windows.Application.Current.MainWindow).splMain.Children.Add(wb);
}
This method gets called at least twice and yet in the output window only 1 image is visible. Where did I get wrong?
EDIT: This is how I am calling The ViewImgData
method:
foreach (SubPod subPod in pod.SubPods)
{
Application.Current.Dispatcher.BeginInvoke(
DispatcherPriority.Background,
new Action(() => ViewImgData(subPod)));
}
EDIT: Is it possible to achieve my intentions with any other control? Thanks?
Upvotes: 0
Views: 94
Reputation: 8295
The problem is that both WebBrowser controls have the Dock property set to Top and the WebBrowser has no minimum width. Meaning the first control will collapse in favour of the 2nd. Try setting the Height/MinHeight property for each WebBrowser or choose some different parent control (why do you use a DockPanel?).
Upvotes: 2