.xaml代码为:
<TreeView x:Name="treeTable" PreviewMouseRightButtonDown="TreeTable_PreviewMouseRightButtonDown">
</TreeView>
.xaml.cs代码为:
IStandaloneTable table1 = iTableCollection.get_StandaloneTable(i);
Image tempImage = new Image();
tempImage.Height = 20;
tempImage.Width = 30;
string path = System.IO.Path.GetFullPath("../../JWCH.AppMain.Ribbon/Resources/Images/attributetubiao.png");
System.Windows.Media.Imaging.BitmapImage bitmapImage = new System.Windows.Media.Imaging.BitmapImage(new Uri(path, UriKind.RelativeOrAbsolute));
tempImage.Stretch = Stretch.Fill;
tempImage.Source = bitmapImage;
TextBlock tempTextBlock = new TextBlock();
tempTextBlock.Inlines.Add(table1.Name);
TreeViewItem mtrnode = new TreeViewItem();
StackPanel sp = new StackPanel();
sp.Orientation = System.Windows.Controls.Orientation.Horizontal;
sp.Children.Add(tempImage);
sp.Children.Add(tempTextBlock);
mtrnode.Header = sp;
treeTable.Items.Add(mtrnode);
treeTable.Items.Refresh();