在SilverLight中代码编写可选择树节点

StackPanel panel = new StackPanel();
                panel.Orientation = Orientation.Horizontal;
                panel.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                panel.Margin = new Thickness(0, 0, 0, 0);
                BitmapImage bitmap = new BitmapImage(new Uri(imgurl, UriKind.Relative));
                Image img = new Image();
                img.Width = 20;
                img.Height = 16;
                img.Source = bitmap;

                CheckBox cb = new CheckBox();
                cb.DataContext = node.getId()+"";
                cb.Width = 20;
                cb.Height = 16;
                if (userdic.ContainsKey(node.getId() + ""))
                {
                    cb.IsChecked = true;
                }
                cb.Checked += new RoutedEventHandler(cb_Checked);
                cb.Unchecked += new RoutedEventHandler(cb_UnChecked);
                TextBlock tb = new TextBlock();
                tb.Text = name;

                panel.Children.Add(cb);
                panel.Children.Add(img);
                panel.Children.Add(tb);                
                node.Header = "";
                node.DefaultImageSrc = null;
                node.Header = panel;
原文地址:https://www.cnblogs.com/lh-V/p/3431120.html