This is a migrated thread and some comments may be shown as answers.

ScrollViewer will not be "auto" when theme is used

1 Answer 139 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Inger Marie
Top achievements
Rank 1
Inger Marie asked on 15 Aug 2011, 08:25 AM
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 ?






1 Answer, 1 is accepted

Sort by
0
Accepted
Vanya Pavlova
Telerik team
answered on 15 Aug 2011, 08:46 AM
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 >>

Tags
General Discussions
Asked by
Inger Marie
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question
or