Why won't this support horizontal scrolling?
<ScrollViewer>
<ItemsControl ItemsSource="{Binding Territories}" HorizontalAlignment="Left">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel CanHorizontallyScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Auto" >
</VirtualizingStackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="75" />
<ColumnDefinition Width="75" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="150" />
<ColumnDefinition Width="65" />
<ColumnDefinition Width="60" />
<ColumnDefinition Width="75" />
<ColumnDefinition Width="75" />
</Grid.ColumnDefinitions>
<TextBox Grid.Row="0" Grid.Column="0" Text="{Binding Quantity, StringFormat=N0, ValidatesOnDataErrors=True}" />
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding ProductionNumber, ValidatesOnDataErrors=True}" />
<ComboBox Grid.Row="0" Grid.Column="2" SelectedValuePath="PrimaryKey" SelectedValue="{Binding RepKey}" ItemsSource="{Binding RepCanidates}" TextSearch.TextPath="FullName" Margin="4">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding FullName}" ToolTip="{Binding FullName}" Width="150" />
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border x:Name="Bd"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}">
<StackPanel Orientation="Horizontal">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<TextBlock Text="{Binding CompanyBranchName}" ToolTip="{Binding CompanyBranchName}" Width="200"/>
<TextBlock Margin="4,0,0,0" Text="{Binding ShortAddress}" ToolTip="{Binding ShortAddress}" />
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ComboBox.ItemContainerStyle>
</ComboBox>
<Button Grid.Row="1" Grid.Column="2" Content="Advanced Search" Name="cmdAdvancedSearch" Click="cmdAdvancedSearch_Click" />
<ComboBox Grid.Row="0" Grid.Column="3" SelectedValuePath="PrimaryKey" SelectedValue="{Binding CompanyBranchKey}" ItemsSource="{Binding CompanyBranchCanidates}" Margin="4" IsEnabled="{Binding CompanyBranchKeyEditable}">
</ComboBox>
<TextBox Grid.Row="0" Grid.Column="4" Text="{Binding ZipCode}" IsEnabled="{Binding ZipCodeEditable}"/>
<ComboBox Grid.Row="0" Grid.Column="5" SelectedValuePath="PrimaryKey" SelectedValue="{Binding StateKey}" ItemsSource="{Binding StateCanidates}" Margin="4" IsEnabled="{Binding StateKeyEditable}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding State}" ToolTip="{Binding StateName}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ComboBox Grid.Row="0" Grid.Column="6" SelectedValuePath="PrimaryKey" SelectedValue="{Binding TerritoryKey, ValidatesOnDataErrors=True}" ItemsSource="{Binding TerritoryCanidates}" Margin="4" IsEnabled="{Binding TerritoryKeyEditable}">
</ComboBox>
<Button Grid.Row="0" Grid.Column="7" Content="Delete" Click="cmdDeleteRow_Click" Margin="4" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
This change will work:
<ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Visible">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With