<ListViewItem Width=”100″ Margin=”1″>
<StackPanel>
<Image Source=”地址”></Image>
<TextBlock>hehe</TextBlock>
</StackPanel>
</ListViewItem>
本人会在后台动态创建listviewitem会,listviewitem的内容的添加怎么用c#表示
<StackPanel>
<Image Source=”地址”></Image>
<TextBlock>hehe</TextBlock>
</StackPanel>
</ListViewItem>
本人会在后台动态创建listviewitem会,listviewitem的内容的添加怎么用c#表示
解决方案
10
ListViewItem listViewItem = new ListViewItem() { Width = 100, Margin = new Thickness(1) }; StackPanel stackPanel = new StackPanel(); Image image = new Image() { Source = new BitmapImage(new Uri("1_guwei4037.jpg", UriKind.Relative)) }; TextBlock textBlock = new TextBlock() { Text = "hehe" }; stackPanel.Children.Add(image); stackPanel.Children.Add(textBlock); listViewItem.Content = stackPanel; grid.Children.Add(listViewItem);
20
ListViewItem listViewItem = new ListViewItem{ Width = 100, Margin = new Thickness(1) };
StackPanel stackPanel = new StackPanel();
Image image = new Image{ Source = new BitmapImage(new Uri(“1_guwei4037.jpg”, UriKind.Relative)) };
TextBlock textBlock = new TextBlock { Text = “hehe” };
stackPanel.Children.Add(image);
stackPanel.Children.Add(textBlock);
listViewItem.Content = stackPanel;
StackPanel stackPanel = new StackPanel();
Image image = new Image{ Source = new BitmapImage(new Uri(“1_guwei4037.jpg”, UriKind.Relative)) };
TextBlock textBlock = new TextBlock { Text = “hehe” };
stackPanel.Children.Add(image);
stackPanel.Children.Add(textBlock);
listViewItem.Content = stackPanel;