0
以下是我用於在此實例中創建車輛列表的XAML - 其中一個車輛是「默認」車輛,並且接下來顯示星形圖像如果默認設置被設置爲「true」。這一切工作正常和丹迪。以編程方式更改WP7(列表框)上的XAML中的圖像
但是,對於明暗主題,我想根據主題將圖像的顏色從白色更改爲黑色。但我無法弄清楚如何做到這一點。我已經嘗試編程創建一個XAML資源並添加它,但似乎不工作。我也嘗試命名圖像(正如你可以在下面看到的「iLPNS」),但是我不能在我的代碼中訪問這個,因爲(我假設)直到列表框包含項目纔會真正存在。
沒有人有任何想法如何,我可以做到這一點?
<controls:PivotItem Header="vehicles" Name="piLPNS">
<Grid>
<TextBlock Text="A list of the vehicles associated with your account are listed below. To make changes to your vehicle list using the buttons below or by tapping the desired vehicle." Margin="12,0,0,0" TextWrapping="Wrap" />
<ListBox Height="300" HorizontalAlignment="Left" Margin="0,135,0,0" Name="lbLPNList" VerticalAlignment="Top" Width="456" SelectionChanged="lbLPNList_SelectionChanged" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate >
<StackPanel Orientation="Horizontal" Height="60" Width="432" HorizontalAlignment="Center">
<StackPanel Orientation="Vertical" Height="60" Width="40" Margin="12,0,0,0">
<StackPanel Orientation="Horizontal" Height="45">
<Image Name="iLPNS" Source="/Parkmobile;component/Resources/Icons/Icon.Star.Resource.png" Margin="0,5,0,0" Visibility="{Binding Default, Converter={StaticResource VisibilityConverter}}" Height="36" Width="36" HorizontalAlignment="Right"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Height="60">
<StackPanel Orientation="Horizontal" Height="45">
<TextBlock Margin="10,0,0,0" FontSize="36" Text="{Binding ShortDisplay}" />
</StackPanel>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</controls:PivotItem>