我在 WP7 中有一个绑定的列表框,每个部分都包含一组项目,我想在单击时更改图标的路径,以便更改单击的图标。这是我的 XAML 数据,需要在单击按钮上更改斜体和粗体的 Stackpanel。
<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>
我以这种方式填写了这个列表框
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;
}
请帮忙..!!