我刚刚开始使用Visual Studio 2010 Express for Windows Phone进行开发,并且我放入了一个ListBox.我似乎无法操纵格式.无论我做什么,背景为黑色/灰色,所选项目都有蓝色边框,列表框中的项目之间有填充(我正在使用图像).这是我的代码:
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>
Run Code Online (Sandbox Code Playgroud)
有什么方法可以自定义列表框吗?喜欢将背景更改为红色或在不同的项目0之间进行填充?
这是一些演示xaml,显示设置一些显示属性.
<ListBox Height="640" HorizontalAlignment="Left" Margin="6,6,0,0" Name="listBox1" VerticalAlignment="Top" Width="468">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Padding" Value="-12" />
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="Black"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
请注意,内置格式化正在应用一些填充,可以使用值-12来处理.我也是从埃里克·弗莱克的帖子明白这里,这可能是地铁风格的结果.该帖子提供了一个如何在按钮控件上完全绕过此格式的示例.这可能是值得考虑的方法.
| 归档时间: |
|
| 查看次数: |
2830 次 |
| 最近记录: |