我刚刚开始使用Visual Studio 2010 Express for Windows Phone进行开发,并将其放入ListBox中。我似乎无法操纵格式。不管我做什么,背景是黑色/灰色,选定的项目都有一个蓝色边框,并且在列表框中的项目之间有填充(我正在使用图像)。这里是我的代码:Windows Phone 7列表框不可自定义?
的XAML:
<Grid x:Name="ContentGrid" Grid.Row="1">
<Grid Name="gallery">
<Grid.RowDefinitions>
<RowDefinition Height="370" />
<RowDefinition Height="150" />
</Grid.RowDefinitions>
<Border BorderBrush="Red" Width="450" CornerRadius="4" BorderThickness="2"
Background="Red" Margin="10,30,20,10" Padding="6,6,6,6">
<Image Grid.Row="0" Grid.Column="0" Height="360" x:Name="imgPreview"/>
</Border>
<ListBox x:Name="lbScrollGallery" Grid.Row="1" Grid.Column="0" Padding="0"
VerticalAlignment="Top" Width="450" SelectionChanged="ScrollerSelectionChanged"
d:LayoutOverrides="HorizontalAlignment" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Width="100" Height="100" Stretch="Fill" Name="imgSource"
VerticalAlignment="Center"
Source="{Binding Path=Url}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
有一些方法我可以自定义列表框?就像将背景改为红色或在不同项目之间填充0一样?
如果按照建议执行,比如实现自己的样式等,则应该能够像桌面上的Silverlight一样覆盖列表框的默认样式 - 请记住,某些填充用于触摸目标,值得在构建自定义控件时记住或者定制现有的图像 - 但是图像将会大到我猜想的目标。 – RoguePlanetoid 2010-06-08 18:57:06