我有Silverlight Sketch项目,我使用muliticolumn listview来模拟datagrid。
<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>
一切正常,但我不知道如何为我的列表框制作漂亮的标题。
答案 0 :(得分:2)
您已经覆盖了控件模板,因此只需在itemspresenter上方放置一个格式正确的textbblock