I have a list box in my app and a button inside that list box. I applied a image to that button (appbar.edit.rest.png icon). but when theme change to light, icon doesn’t display…what should i do to dynamic change that icon when theme changed. Xaml code is as follows:
<ListBox x:Name="passwordSaferRecordsListBox" ItemsSource="{Binding EntityRecordInfoItems}" Grid.Row="0" Margin="12, 140, 0, 0" FontSize="40" HorizontalAlignment="Center" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Stretch" Width="440">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Text="{Binding RecordName}"
FontSize="{StaticResource PhoneFontSizeLarge}"
Grid.Column="0"
VerticalAlignment="Center"/>
<Button
Grid.Column="1"
x:Name="editTaskButton"
BorderThickness="0"
Margin="0"
Click="editTaskButton_Click" DataContext="{Binding}">
<Image Source="appbar.edit.rest.png"></Image>
</Button>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
You can use a viewmodel with an ImageUri:
Then you go to your XAML and bind the image:
I hope this will help you!