以编程方式更改WP7上XAML中的图像(列表框)
下面是我在本例中用于创建车辆列表的XAML——其中一辆车是“默认”车辆,如果默认设置设置为“true”,则会在旁边显示一个星形图像。这些都很好用 但是,对于浅/暗主题,我想根据主题将图像的颜色从白色更改为黑色。但是我不知道怎么做。我曾尝试通过编程方式创建XAML资源并添加它,但这似乎不起作用。我还尝试过给图像命名(如下面“iLPNS”所示),但是,我无法在我的代码隐藏中访问它,因为(我假设)它在列表框包含项目之前并不存在 有人知道我该怎么做吗以编程方式更改WP7上XAML中的图像(列表框),xaml,windows-phone-7,Xaml,Windows Phone 7,下面是我在本例中用于创建车辆列表的XAML——其中一辆车是“默认”车辆,如果默认设置设置为“true”,则会在旁边显示一个星形图像。这些都很好用 但是,对于浅/暗主题,我想根据主题将图像的颜色从白色更改为黑色。但是我不知道怎么做。我曾尝试通过编程方式创建XAML资源并添加它,但这似乎不起作用。我还尝试过给图像命名(如下面“iLPNS”所示),但是,我无法在我的代码隐藏中访问它,因为(我假设)它在列表框包含项目之前并不存在 有人知道我该怎么做吗 <controls:PivotItem Hea
<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>
在模板中包含图像的两个版本,然后在每个版本上使用转换器,根据当前主题更改可见性