ScrollViewer will not be "auto" when theme is used

2 posts, 1 answers
  1. Inger Marie
    Inger Marie avatar
    86 posts
    Member since:
    Nov 2010

    Posted 15 Aug 2011 Link to this post

    I have these two styles defines in separate resourcedictionary files in a separate project:

     <Style TargetType="ScrollViewer">
            <Setter Property="telerik:StyleManager.Theme"  Value="Windows7" />
        </Style>

        <Style x:Key="ListViewNoHighlightSelection"         TargetType="ListView">
            <Style.Resources>
                <!-- Background of selected item when focussed -->
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
                <!-- Background of selected item when not focussed -->
                <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
            </Style.Resources>
        </Style>

    This is how I use this style:

     

      <ListView x:Name="advertFormatSelector"  Grid.Row="0"       Grid.Column="0"
                          Grid.ColumnSpan="7"
                          Margin="2,2"
                          BorderThickness="0"
                          ItemsSource="{Binding BasketItemTemplates}"
                          SelectedItem="{Binding SelectedBasketItemTemplate, Mode=TwoWay}"
                          MaxHeight="100"
                          >
                    <ListView.Style>
                        <Style BasedOn="{StaticResource ListViewNoHighlightSelection}"
                               TargetType="{x:Type ListView}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Path=Dimensions}"
                                             Value="{x:Null}">
                                    <Setter Property="BorderBrush"
                                            Value="{StaticResource ErrorBrush}" />
                                    <Setter Property="BorderThickness"
                                            Value="2" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ListView.Style>
                    <ListBox.ItemContainerStyle> .. </ListBoxItemContainerStyle>
        <ListView.ItemTemplate>...    </ListView.ItemTemplate>
                </ListView>

    My problem is that the scrollviewer is displayed but it is non-functional (grayed out) since the listview has all the space it needs. I guess showing non-functional scrollbars are part of the theme, but I want no scrollbar when no scrolling is nessesary. I do not want that scrollviewer to be displayed. Adding:

            <Setter Property="VerticalScrollBarVisibility"  Value="Auto" />
            <Setter Property="HorizontalScrollBarVisibility"  Value="Auto" />
    (or even setting the value to Disabled)

    acheives nothing - I've tried to apply these lines to ListViewNoHighlightSelection, to my listview and to its style.

    Why do the GUI behave like that and how do I make the scrollbar dissappear ?






  2. Answer
    Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 15 Aug 2011 Link to this post

    Hello Inger,

     

    You should set these properties in an attached manner as shown below:


    <Style TargetType="ScrollViewer">
            <Setter Property="telerik:StyleManager.Theme" Value="Windows7"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/>
        </Style>
        </Window.Resources>
        <Grid x:Name="LayoutRoot">
            <ScrollViewer telerik:StyleManager.Theme="Windows7" Margin="128,40,136,66" Height="100"/>


    Kind regards,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Back to Top