我剛剛開始使用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