I am using dockpanel to display a list of buttons that are read from an itemsource and want to display them horizontally but it displays them vertically.
I am using the following code:
<DockPanel Name="DockPanel2" Grid.Row="1" Visibility="Visible">
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="260,50,0,0">
<ItemsControl ItemsSource="{Binding PageViewModels}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Foreground="MidnightBlue"
Content="{Binding Name}" Command="{Binding DataContext.ChangePageCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
CommandParameter="{Binding }"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
<ContentControl Content="{Binding CurrentPageViewModel}"/>
</DockPanel>
If I use the following code (taking buttons as static list I am able to display the list in a horizontal fashion.
<DockPanel Name="DockPanel2" Grid.Row="1" Visibility="Visible">
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="260,50,0,0">
<Button Content="Button 1" Margin="2" />
<Button Content="Button 2" Margin="2" />
<Button Content="Button 3" Margin="2" />
<Button Content="Button 4" Margin="2" />
<Button Content="Button 5" Margin="2" />
</StackPanel>
<ContentControl Content="{Binding CurrentPageViewModel}" />
</DockPanel>
Can someone tell me where am I going wrong.
Thanks, T