tags:

views:

195

answers:

3

Curve the border of silverlight listbox control:

I just want to curve the ends of the silverlight listbox border.

Is there any thing wrong I am doing , because i am not able to get the borders curve :

  <Style TargetType="ListBox" x:Key="listboxStyle">
    <Setter Property="Padding" Value="1"/>
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="VerticalContentAlignment" Value="Top" />
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="BorderThickness" Value="0" />
    <Setter Property="TabNavigation" Value="Once" />
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="ListBox">
          <Grid Background="White">
              <Border Background="White" BorderThickness="0" CornerRadius="10">
                <ScrollViewer Background="White" x:Name="ScrollViewerElement" Padding="{TemplateBinding Padding}">
                  <ItemsPresenter />
                </ScrollViewer>
              </Border>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
A: 

Please check on how to edit the control template of a ListBox(or any WPF control) - http://msdn.microsoft.com/en-us/library/ms754242.aspx You can give CornerRadius on the Border inside the controltemplate.

Jobi Joy
A: 

Check this section Minimally templated ListBox and ListBoxItem with Template and ControlTemplate:

of that blogpost

http://blogs.msdn.com/delay/archive/2008/03/05/lb-sv-faq-examples-notes-tips-and-more-for-silverlight-2-beta-1-s-listbox-and-scrollviewer-controls.aspx

The author of the blog is the writer of the listbox control (as I remember).

silverfighter
+2  A: 

Ok I got it done and there was no need to style the listbox control .

    <Border BorderBrush="White" BorderThickness="0" CornerRadius="5" Background="White" >
       <ListBox x:Name="lstEnities" BorderThickness="0" Margin="5" Grid.Row="0"></ListBox>
    </Border>
Malcolm
Nice and very elegant, composition FTW, +1
Florian Doyon