Why doesn't the ScrollViewer limit vertical expansion? - wpf

I've been working with WPF for several years, now, yet the layout mechanism often makes me feel like a noob (and maybe I still am). My page is fairly complex. Below, I've eliminated much of the unrelated content, but left the general structure of the page in tact. I have two ItemsControls. Both have ScrollViewers. They both used to have the ScrollViewrs wrapping the <ItemsPresenter />. A post I saw had me try moving the first one to wrap the entire ItemsControl to see if that fixed my issue. It did not.
The main differences between the ItemsControls is that the first has a series of DataTemplates for the content, where the second defines the content inline.
Everything displays properly with the exception that the first one forces its Grid cell to expand to accommodate all content, rather than enabling the vertical scroll bar. The second instance, properly activates the ScrollViewer when the content is to long.
What am I missing? (Hopefully something stupid I just missed.)
Here's my XAML:
<vsupport:CBUserControlBase x:Class="CB.WPFClient.Views.BillingMasterView" ... >
<vsupport:CBUserControlBase.Resources>
<Storyboard>
<ThicknessAnimation />
</Storyboard>
<Storyboard>
<ThicknessAnimation />
</Storyboard>
</vsupport:CBUserControlBase.Resources>
<Grid Margin="1" IsEnabled="{Binding Path=IsBusy, Converter={StaticResource BoolInverse}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<local:FirmSelectorView Grid.Row="0" Margin="1,1,1,1"/>
<Grid Grid.Row="1" ClipToBounds="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Margin="1,0,0,0">
<!-- Unrelated Content -->
</Grid>
<Grid Grid.Column="1" Margin="1,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="White">
<!-- Unrelated Content -->
</Grid>
<Grid Grid.Row="1" Margin="0,1,0,0">
<!-- Unrelated Content -->
</Grid>
<Grid Grid.Row="2" Margin="0,1,0,0">
<!-- Unrelated Content -->
</Grid>
<Grid Grid.Row="3" Margin="0,1,0,0">
<!-- Unrelated Content -->
</Grid>
<!-- Notes and Related Entities -->
<Grid Grid.Row="4" Margin="0,1,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<!-- Unrelated Content -->
</Grid>
<!-- Related Entities -->
<Grid Grid.Column="1" Margin="1,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Column="0" Background="{StaticResource brush_Logo}" Foreground="White" Padding="5,0,0,0" Height="24"
HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
Content="Related Entities" />
<!-- This one expands when multiple content items are longer than vertical space. -->
<!-- Scroll viewer used to be inside ItemsControl. Tried moving it to see if that helped. -->
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Hidden">
<ItemsControl ItemsSource="{Binding Path=RelatedEntities}" x:Name="RelatedEntitiesItemsControl">
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type models:C}">
<Grid Margin="2,2,2,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" CornerRadius="5,0,0,5" Padding="0,2,0,2">
<TextBlock Foreground="White" FontSize="10" Background="Transparent">
</TextBlock>
</Border>
<Border Grid.Column="1" Background="#FFF5F7FF" CornerRadius="0,5,5,0" Margin="3,0,0,0">
<Grid>
</Grid>
</Border>
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type models:P}">
<Grid Margin="2,2,2,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" CornerRadius="5,0,0,5" Padding="0,2,0,2" Background="{StaticResource brush_Plan}">
<TextBlock Foreground="White" FontSize="10" Background="Transparent">
</TextBlock>
</Border>
<Border Grid.Column="1" Background="#FFF5F7FF" CornerRadius="0,5,5,0" Margin="3,0,0,0">
<Grid>
</Grid>
</Border>
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type models:A}">
<Grid Margin="2,2,2,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" CornerRadius="5,0,0,5" Padding="0,2,0,2" Background="{StaticResource brush_Account}">
<TextBlock Foreground="White" FontSize="10" Background="Transparent">
</TextBlock>
</Border>
<Border Grid.Column="1" Background="#FFF5F7FF" CornerRadius="0,5,5,0" Margin="3,0,0,0">
<Grid>
</Grid>
</Border>
</Grid>
</DataTemplate>
</ItemsControl.Resources>
<ItemsControl.Template>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<!-- Old ScrollViewer Location -->
<ItemsPresenter />
<!-- Old ScrollViewer Location -->
</ControlTemplate>
</ItemsControl.Template>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
</Grid>
<ContentControl Grid.Row="1">
</ContentControl>
<Grid Grid.Row="2" Margin="0,1,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
</Grid>
<Grid Grid.Column="1" Margin="1,0,0,0">
</Grid>
<!-- This one works properly -->
<Grid Grid.Column="2" Margin="1,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
</Grid>
<ItemsControl Grid.Row="1" AlternationCount="2" ItemsSource="{Binding Path=Stuff}">
<ItemsControl.Template>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto">
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,1,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label />
<Label />
</Grid>
<DataTemplate.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="WhiteSmoke" TargetName="StaticTextLabel" />
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="{StaticResource brush_LogoLight}" TargetName="StaticTextLabel" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Grid>
<Grid Grid.Row="3" Margin="0,1,0,0">
</Grid>
</Grid>
</Grid>
</Grid>
</vsupport:CBUserControlBase>

Just a tip....you'll have a bit better luck getting answers in future by providing a proper MCVE. In this particular case your issue can be boiled down to this:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Hidden">
<ItemsControl>
<ItemsControl.ItemsSource>
<x:Array Type="{x:Type sys:String}">
<sys:String>Hello World</sys:String>
<sys:String>Goodbye World</sys:String>
<sys:String>Hello World</sys:String>
<sys:String>Goodbye World</sys:String>
<!-- ... etc ... -->
<sys:String>Hello World</sys:String>
<sys:String>Goodbye World</sys:String>
</x:Array>
</ItemsControl.ItemsSource>
</ItemsControl>
</ScrollViewer>
</Grid>
When you do Height="Auto" in your row definition you're basically saying "give the controls on this row as much space as they need, which ScrollViewer promptly does irrespective of how much space its parent has. When you use Auto in conjunction with more than one row you're effectively telling the layout manager that you are expecting the first row to never exceed the amount of available space...otherwise, why would you declare another row beneath it?
The reason WPF layout is tricky is because it's different to most other layouts. Most things start at the top and work their way down, figuring out how much space to allocate based on how much is available. WPF starts by asking each control how much it wants, and then works it's way up. Once it gets to the top THEN it walks back down assigning actual sizes. So in your case you've got this ScrollViewer asking for more space than is actually available, but it's inside about 7 or 8 layers of nested Grid panels. At each level while walking up the tree the layout manager is looking at these saying "how should I split the available space amongst this Grid's children?", and each one of these is specifying "Auto" for the row in question, which is effectively saying "give this particular row as much as it wants, even if it's more than I have to offer".
I know this probably isn't what you want to hear but my suggestion would be to throw the whole layout out and start again. RowSpan and ColumnSpan are absolutely key in layouts like this, if you start using them then you'll find you can collapse the entire thing down to just a few nested layers, and you won't have ScrollViewer problems like the one above. If that's not an option then you're going to have to walk up the visual tree yourself changing each RowDefinition from Auto to something else that better meets your actual GUI requirements.

Related

Silverlight PivotItem not scrolling down

PivotItem can't scroll down... Anyone has any ideas as to how I can remedy this?
For whatever the reason just won't scroll down when content that is bound inside the listbox is longer than the height of the page. I tried adding a grid inside the pivotitem with height set to auto, but to no avail.
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<controls:Pivot Height="Auto">
<controls:PivotItem Header="Main Information">
<Border CornerRadius="10" Background="#FF5C7590" Height="Auto" Padding="2" BorderThickness="1">
<ListBox x:Name="lbxPropertyItems">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Margin="5, 0, 0, 0" Grid.Column="0" Text="{Binding Label}" />
<TextBlock Grid.Column="1" Text="{Binding Value}" TextWrapping="Wrap" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
</controls:PivotItem>
</controls:Pivot>
</Grid>
Thanks for any advice.
The issue is that a StackPanel has an infinite layout space in which ever orientation it is set, so the ScrollViewer included in the ListBox never gets activated in that direction. The best way to handle it is to host it inside a Grid control with row or column definitions.

Complex controls in a Popup

I am building a control allowing to manage some items and select one.
It comprises a TextBox and a Button allowing to open a Popup where it all happens.
I would like to have a list of items with details in a System.Windows.Controls.Primitives.Popup class. I am using a Grid with 2 columns, the first one contains the list of items, the second one its details.
Now I want to use a System.Windows.Controls.GridSplitter control to allow the user to resize the area of details.
The problem is that this works everywhere except of inside a Popup control.
My question is, should I use some other control simulating Popup's behavior (Window..) or is there any other way to achieve this.
EDITED:
If I set Width Property of the Popup it works, because the Popup is not trying to adapt to its content. But I want to preserve this behaviour..
What I'm planning is to add complex animations to the controls in the Popup as well.
CODE:
...
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBox Grid.Column="0" Grid.Row="0" Text="Selected Item" />
<ToggleButton Grid.Row="0" Grid.Column="1" Focusable="False">
<Grid>
<TextBlock Text="Select" />
<Popup StaysOpen="False" Width="700" VerticalAlignment="Bottom" IsOpen="{Binding Path=IsChecked,
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ToggleButton, AncestorLevel=1},
Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" PlacementTarget="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ToggleButton, AncestorLevel=1}}">
<local:MyManagementControl />
</Popup>
</Grid>
</ToggleButton>
</Grid>
...
MyManagementControl contains:
...
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView Grid.Row="0" Grid.Column="0">
...
</ListView>
<GridSplitter Grid.Column="0" Width="10" HorizontalAlignment="Right" VerticalAlignment="Stretch" />
<Grid Grid.Row="0" Grid.Column="1">
...Details...
</Grid>
</Grid>
...

How do I get a TextBox to fill a resizable column?

I'm trying to get a TextBox to fill the available space in a resizable column. The TextBox is part of a user control:
<UserControl x:Class="TextBoxLayout.FieldControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0">Name</Label>
<TextBox Grid.Column="1"/>
</Grid>
</UserControl>
This user control is in a window with a vertical splitter:
<Window x:Class="TextBoxLayout.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TextBoxLayout"
Title="Text box layout" Height="400" Width="600">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="100"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition MinWidth="100"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<local:FieldControl Grid.Column="0" Grid.Row="0" MaxWidth="200" HorizontalAlignment="Left"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Testing"/>
<GridSplitter Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="3"/>
<TextBlock Grid.Column="2" Grid.Row="0" Grid.RowSpan="2" Text="Testing"/>
</Grid>
</Window>
The problem is the TexTBox appears to be very narrow - what I'd want it to do is fill the left column and resize with the splitter. How do I do that?
Use HorizontalAlignment="Stretch" instead of "Left" for FieldControl. Remove MaxWidth if required. Use TextAlignment to align text.
Just wanted to add to more examples for future code searches.
I put this in the top of the xaml file:
<UserControl.Resources>
<Style TargetType="{x:Type TextBlock}" x:Key="CenterCell">
<Setter Property="Background" Value="{Binding Included, Converter={StaticResource BoolToColorConverter}}"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="TextAlignment" Value="Center"/>
</Style>
</UserControl.Resources>
And then in the datagrid:
<DataGridTextColumn Header="Excluded" Binding="{Binding Excluded}" ElementStyle="{StaticResource CenterCell}"/>
This centers the text and sorting is still enabled. The textbox fills the cell and in this case is colored using a bool converter.
just see whether is that you want
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="100" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition MinWidth="100" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<local:FieldControl Grid.Column="0"
Grid.Row="0"
Margin="2"
/>
<TextBlock Grid.Column="0"
Grid.Row="1"
Text="Testing" />
<GridSplitter Grid.Column="1"
Grid.Row="0"
Grid.RowSpan="2"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Width="3" />
<TextBlock Grid.Column="2"
Grid.Row="0"
Grid.RowSpan="2"
Text="Testing" />
</Grid>

WPF combobox items list/context menu rendered behind parent

If the ItemSource property of a combo box has been set, why could clicking on the drop down botton of a combobox not display the list of available items? This may be related but within the same control, any context menu is displayed behind the user control:
The XAML for this control is as follows:
<Border Name="Border" Padding="5">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ScrollViewer.Resources>
<Style TargetType="{x:Type CheckBox}">
<Setter Property="Padding" Value="8,0,0,0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
</ScrollViewer.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Margin="5,4,0,4" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
<ColumnDefinition SharedSizeGroup="labelColumn1" />
<ColumnDefinition SharedSizeGroup="labelColumn2" />
<ColumnDefinition SharedSizeGroup="dataEntryColumn" />
<ColumnDefinition Width="30"/>
<ColumnDefinition SharedSizeGroup="labelColumn2"/>
<ColumnDefinition SharedSizeGroup="dataEntryColumn" />
<ColumnDefinition MaxWidth="0" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition MinHeight="23" />
<RowDefinition MinHeight="23" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="Geometry Type" VerticalAlignment="Center" Grid.Column="1" Grid.Row="0"/>
<ComboBox Grid.Column="3" Margin="6,1,0,1" Grid.Row="0" Width="150"
Name="cmboGeometryTypes"
SelectedItem="{Binding GeometryType, Mode=TwoWay}"
HorizontalAlignment="Left"
DisplayMemberPath="Name"
Grid.ColumnSpan="1"
/>
<TextBlock Text="Symbol Type"
Grid.Column="1" Grid.Row="1" VerticalAlignment="Center"/>
<ComboBox
Name="cmboSymbolEditors"
SelectedItem="{Binding SymbolEditorViewModel, Mode=TwoWay}"
HorizontalAlignment="Left"
DisplayMemberPath="Alias"
Width="150"
Grid.Column="3"
Margin="6,1,0,1"
Grid.Row="1"
Grid.ColumnSpan="1" />
</Grid>
<Label Padding="10,0,0,0" Margin="10,0,0,3" Style="{StaticResource fadingLabelSeperatorStlye}" Grid.Row="1">
Editor
</Label>
<local:SymbologyEditorControl x:Name="editor" Grid.Row="2"/>
</Grid>
</ScrollViewer>
</Border>
and the effect I am observing is illustrated below
How do I fix this?
There was a common WPF bug that caused this behavior of any Popup type UI displaying in back instead of topmost so that may be what you're seeing. I haven't seen the issue in a while but I'm not sure if it was fixed or not. It's related to bad video drivers so you might see it only on certain machines and not all the time.
There was a hotfix available from MS support but it might be easier to just switch your application to use software rendering instead.

Silverlight - Layout Question

I am creating a Silverlight application that should take up the width of the user's screen. This application has a horizontal row that greets the user. Then, two columns below it. The right column is always a fixed size. I want the left column to take up any remaining space. In an attempt to accomplish this, I am using the following XAML:
<Grid x:Name="layoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid x:Name="greetingGrid" Margin="0,0,0,8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Welcome " />
<TextBlock x:Name="usernameTextBlock" />
</StackPanel>
</Grid>
<Grid x:Name="contentGrid" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid x:Name="leftGrid" HorizontalAlignment="Stretch">
<Border x:Name="leftBorder" BorderBrush="Black" Height="250">
<!-- Insert Wrap Panel of Images --!>
</Border>
</Grid>
<Grid x:Name="rightGrid" Width="100" Grid.Column="1" HorizontalAlignment="Right" Margin="8,0,0,0">
<Border BorderBrush="Black" BorderThickness="2">
<StackPanel Orientation="Vertical">
<TextBlock Text="How would you like to view the images?" />
<ComboBox x:Name="optionComboBox">
<ComboBoxItem Content="Name" />
<ComboBoxItem Content="Date" />
</ComboBox>
</StackPanel>
</Border>
</Grid>
</Grid>
</Grid>
Oddly, the two lower columns are split evenly in size. How do I make the left column take up all remaining space?
Thank you!
<Grid.ColumnDefinitions>
<ColumnDefinition width="*" />
<ColumnDefinition width="250"/>
</Grid.ColumnDefinitions>
Use * for the grid column to take the rest of the available space. Keep in mind that the parent container also needs to take the whole area to make it work!
You can specify the widths of the columns rather than on your "rightGrid", eg:
<Grid x:Name="greetingGrid" Margin="0,0,0,8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Welcome " />
<TextBlock x:Name="usernameTextBlock" />
</StackPanel>
</Grid>
<Grid x:Name="contentGrid" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="100px" />
</Grid.ColumnDefinitions>
<Grid x:Name="leftGrid" HorizontalAlignment="Stretch" Background="Fuchsia">
<Border x:Name="leftBorder" BorderBrush="Black" Height="250">
</Border>
</Grid>
<Grid x:Name="rightGrid" Grid.Column="1" HorizontalAlignment="Right" Margin="8,0,0,0">
<Border BorderBrush="Black" BorderThickness="2">
<StackPanel Orientation="Vertical">
<TextBlock Text="How would you like to view the images?" />
<ComboBox x:Name="optionComboBox">
<ComboBoxItem Content="Name" />
<ComboBoxItem Content="Date" />
</ComboBox>
</StackPanel>
</Border>
</Grid>

Resources