代码之家  ›  专栏  ›  技术社区  ›  zidane

如何在Silverlight中制作列表框标题

  •  3
  • zidane  · 技术社区  · 14 年前

    我有Silverlight草图项目,我正在使用muliticolumn listview来模拟数据报。

    <Style x:Key="ListBox-Sketch" TargetType="ListBox">
        <Setter Property="Padding" Value="1"/>
        <Setter Property="Foreground" Value="#FF000000"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="TabNavigation" Value="Once"/>
        <Setter Property="ItemContainerStyle" Value="{StaticResource ListBoxItem-Sketch}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBox">
                    <Grid>
                        <ScrollViewer x:Name="ScrollViewer" Style="{StaticResource ScrollViewer-Sketch2}" 
                            ScrollViewer.HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" 
                            ScrollViewer.VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="0" 
                            Padding="{TemplateBinding Padding}" 
                            Background="{TemplateBinding Background}" 
                            Foreground="{TemplateBinding Foreground}">
                            <ItemsPresenter/>
                        </ScrollViewer>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="BorderBrush" Value="{StaticResource BaseBorder-Sketch}"/>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="20"></ColumnDefinition>
                            <ColumnDefinition Width="300"></ColumnDefinition>
                            <ColumnDefinition Width="180"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" FontFamily="{StaticResource FontFamily-Sketch}" FontSize="13" Text="{Binding Sifra}" TextWrapping="Wrap" Margin="2"/>
                        <TextBlock Grid.Column="1" FontFamily="{StaticResource FontFamily-Sketch}" FontSize="13" Text="{Binding Naziv}" TextWrapping="Wrap" Margin="2"/>
                        <TextBlock Grid.Column="2" FontFamily="{StaticResource FontFamily-Sketch}" FontSize="13" Text="{Binding Klasifikacija}" TextWrapping="Wrap" Margin="2"/>
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    

    一切都很好,除了我不知道如何为我的列表框做好看的标题。

    1 回复  |  直到 13 年前
        1
  •  2
  •   Chris Haines    13 年前