locked
Set style on a Autcomplete's scrollviewer RRS feed

  • Question

  • I am using the autocomplete from the silverlight toolkit and want to change the style of the scrollviewer.
    In app.xaml I have the autocomplete style def and its popup def looks like this
     <Popup x:Name="Popup" OpacityMask="Transparent">
                                    <Border HorizontalAlignment="Stretch" x:Name="PopupBorder" Opacity="0.0" Background="Transparent" BorderThickness="0" CornerRadius="3">
                                        <Border.RenderTransform>
                                            <TranslateTransform X="1" Y="1"/>
                                        </Border.RenderTransform>
                                        <Border HorizontalAlignment="Stretch" Opacity="1.0" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3" Padding="0">
                                            <Border.RenderTransform>
                                                <TransformGroup>
                                                    <TranslateTransform X="-1" Y="-1"/>
                                                </TransformGroup>
                                            </Border.RenderTransform>
                                            <Border.Background>
                                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                    <GradientStop Color="Black" Offset="0"/>
                                                    <GradientStop Color="Black" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Border.Background>
                                            <ListBox x:Name="SelectionAdapter" ItemTemplate="{TemplateBinding ItemTemplate}"
                                                     Style="CustomListBoxStyle"
                                                     ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto"                                                 
                                                     ItemContainerStyle="{TemplateBinding ItemContainerStyle}"/>

                                        </Border>
                                    </Border>
                                </Popup>

    As you see I call CustomListBoxStyle
    This looks like the following and are also located in app.xaml
    <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListBox">
                            <Grid x:Name="LayoutRoot" Background="White">
                                <Border Padding="0" CornerRadius="0">
                                    <ScrollViewer x:Name="ScrollViewerElement"                                  
                                        ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                                                  ScrollViewer.VerticalScrollBarVisibility="Auto"
                                        Style="{StaticResource ScrollViewerStyle}"
                                        Padding="{TemplateBinding Padding}">                                   
                                    </ScrollViewer>
                                </Border>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>

    Now the ScrollViewerStyle definition works great so im not posting it here. It works 5 other places where I use it.
    If I remove this line
    Style="CustomListBoxStyle"
    from the autocomplete popup style defenition it works great.

    why doesnt this work?

    Thursday, June 11, 2009 10:01 AM

Answers

  •  Hi,

    Now the ScrollViewerStyle definition works great so im not posting it here. It works 5 other places where I use it.
    If I remove this line
    Style="CustomListBoxStyle"
    from the autocomplete popup style defenition it works great.
     

    You cannot se the value for the listbox's style  property. If you can want to use make defined style appliyed for the listbox, you can do like below:

     Style="{StaticResource CustomListBoxStyle}"

    Tuesday, June 16, 2009 5:41 AM