I have got a binded listbox in WP7 containing a set of items in each portion, i want to change the icon’s path when clicked so that the clicked icon is changed.
This is my XAML data and the Stackpanel which is in Italic and Bold needs to be changed on the click button.
<ListBox Height="768" HorizontalAlignment="Left" Name="listBox1" Margin="0,0,0,0"
VerticalAlignment="Top" Width="480" Grid.RowSpan="2" >
<ListBox.ItemTemplate>
<DataTemplate>
<Button BorderBrush="Black" Width="460" Height="100">
<Button.Content>
<StackPanel Orientation="Horizontal" Height="80" Width="400">
<Image Source="{Binding Image}" Width="80" Height="50"/>
<StackPanel Orientation="Vertical" Height="80">
<StackPanel Orientation="Horizontal" Height="40">
<TextBlock Width="200" FontSize="28" Text="{Binding Name}" Height="50"/>
<StackPanel Orientation="Horizontal">
***<Image Source="{Binding OnOff}" Width="100" Height="40" Tap="Image_Tap"/>***
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</Button.Content>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I have filled this listbox in this way
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
List<settings> settingsData = new List<settings>();
settingsData.Add(new settings("Administrator","Images/ad.png",""));
settingsData.Add(new settings("Wi-Fi","Images/wifi.png","Images/off.png"));
settingsData.Add(new settings("Bluetooth", "Images/BlueTooth.png", "Images/On.png"));
settingsData.Add(new settings("Airplane Mode", "Images/747.png", "Images/off.png"));
settingsData.Add(new settings("VPN", "", ""));
settingsData.Add(new settings("Hotspot", "", "Images/unchecked.png"));
settingsData.Add(new settings("NFC", "", "Images/checked.png"));
settingsData.Add(new settings("Sound","Images/sound.png",""));
settingsData.Add(new settings("Display","Images/display.png",""));
listBox1.ItemsSource = settingsData;
}
Help please..!!
A quick solution is,