views:

148

answers:

1

Hello,

i cant find how to set scrollbar to scroll horizontaly with mouse. Vertical scrolling works good allways, but i need to scroll my content horizontaly. My code looks like this:

<ListBox x:Name="receiptList"
                       Margin="5,0"
                       Grid.Row="1"
                       ItemTemplate="{StaticResource receiptListItemDataTemplate}"
                       ItemsSource="{Binding OpenReceipts}"
                       ScrollViewer.VerticalScrollBarVisibility="Disabled"
                           >
                <ItemsControl.ItemsPanel>
                  <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" ScrollViewer.HorizontalScrollBarVisibility="Visible"/>
                  </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
              </ListBox>

My item tamplate looks like this:

<DataTemplate x:Key="receiptListItemDataTemplate">
        <RadioButton 
            GroupName="Numbers"
                Command="{Binding Path=DataContext.SelectReceiptCommand,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type POS:PointOfSaleControl}}}"
                CommandParameter="{Binding }"
                Margin="2,0"
            IsChecked="{Binding IsSelected}">
          <RadioButton.Template>
            <ControlTemplate TargetType="{x:Type RadioButton}" >
                <Grid x:Name="receiptGrid" >
                  <Grid>
                    <Border BorderThickness="2" BorderBrush="Green" Height="20" Width="20">
                      <Grid x:Name="radioButtonGrid" Background="DarkOrange">
                        <TextBlock x:Name="receiptLabel" HorizontalAlignment="Center" VerticalAlignment="Center"
                               Text="{Binding Path=NumberInQueue, Mode=OneWay}"
                               FontWeight="Bold"
                               FontSize="12"
                               Foreground="White"
                                           >
                        </TextBlock>
                      </Grid>
                    </Border>
                  </Grid>
                </Grid>

              <ControlTemplate.Triggers>
                <Trigger Property="IsChecked" Value="True">
                  <Setter Property="Margin" TargetName="receiptGrid" Value="2,2,-1,-1"/>
                  <Setter Property="Background"
                          TargetName="radioButtonGrid" Value="Maroon"/>
                </Trigger>
              </ControlTemplate.Triggers>
            </ControlTemplate>
          </RadioButton.Template>
        </RadioButton>

    </DataTemplate>

Maybe there is some other oportunity to do that with some other control?

A: 

Try this:

<ListBox x:Name="receiptList" 
                       Margin="5,0" 
                       Grid.Row="1" 
                       ItemTemplate="{StaticResource receiptListItemDataTemplate}" 
                       ItemsSource="{Binding OpenReceipts}" 
                       ScrollViewer.VerticalScrollBarVisibility="Disabled" 
                       ScrollViewer.HorizontalScrollBarVisibility="Visible"
                           > 
                <ItemsControl.ItemsPanel> 
                  <ItemsPanelTemplate> 
                    <StackPanel Orientation="Horizontal" /> 
                  </ItemsPanelTemplate> 
                </ItemsControl.ItemsPanel> 
</ListBox> 

UPDATE Ooops, missed the part about the mouse wheel! Sorry

To make the mouse wheel work, you will have to subscribe to the mouse wheel event and manuaaly move the scroll bar... This can nicelly be encapsulated by a behavior but I think thats the only way to make it work!

rudigrobler
This does not works. it works only with keyborad "->" and "<-". Moruse wheel scroll does not work.
Vytas999