找回密码
 立即注册

QQ登录

只需一步,快速开始

yingjunn

银牌会员

7

主题

11

帖子

2757

积分

银牌会员

积分
2757

活字格认证

yingjunn
银牌会员   /  发表于:2013-5-28 09:20  /   查看:6105  /  回复:4
问题:根据父节点 动态加载子节点,但是如果没有子节点,三角形图片就不显示。
需要在没有子节点的情况下把图片显示出来。

4 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-5-28 12:13:00
沙发
回复 1楼yingjunn的帖子

yingjunn 你好,

目前 C1TreeView 没有提供相关接口去设置 三角号 是否显示,我们边正在尝试通过自定义 style 方法实现,有结果我会更新帖子状态。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-5-28 15:32:00
板凳
回复 2楼iceman的帖子

目前问题状态:
MSDN 中查阅了 TreeViewItem Style 相关信息,当然这并不能解决 C1TreeView 的问题,只是把现有进度共享:
是通过以下这段代码实现的:

  1.                       <vsm:VisualStateGroup x:Name="HasItemsStates">
  2.                             <vsm:VisualState x:Name="HasItems" />
  3.                             <vsm:VisualState x:Name="NoItems">
  4.                                 <Storyboard>
  5.                                     <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ExpanderButton" Storyboard.TargetProperty="Visibility" Duration="0">
  6.                                         <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />
  7.                                     </ObjectAnimationUsingKeyFrames>
  8.                                 </Storyboard>
  9.                             </vsm:VisualState>
  10.                         </vsm:VisualStateGroup>
复制代码

Demo:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-5-28 15:38:00
地板
回复 2楼iceman的帖子

实现思路大体相同,我们会继续跟进该问题,有结果会及时更新帖子状态。
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2013-5-29 11:16:00
5#
为叶子节点添加图片的代码如下,主要思路是指定C1TreeViewItem.Header属性

  1.     public partial class MainPage : UserControl
  2.     {
  3.         public MainPage()
  4.         {
  5.             InitializeComponent();

  6.             InitializeTreeView();
  7.         }

  8.         void InitializeTreeView()
  9.         {
  10.             // Remove items that were added at design time
  11.             c1TreeView1.Items.Clear();

  12.             c1TreeView1.ShowLines = false;

  13.             C1TreeViewItem booklist = new C1TreeViewItem();
  14.             booklist.Header = &quot;Book List&quot;;
  15.             c1TreeView1.Items.Add(booklist);

  16.             // Adding child items
  17.             C1TreeViewItem language = new C1TreeViewItem();
  18.             language.Header = &quot;Language Books&quot;;
  19.             booklist.Items.Add(language);

  20.             // Adding child items
  21.             C1TreeViewItem security = new C1TreeViewItem();
  22.             security.Header = &quot;Security Books&quot;;
  23.             booklist.Items.Add(security);

  24.             // Adding child items
  25.             C1TreeViewItem classic = new C1TreeViewItem();
  26.             classic.Header = &quot;Classic Books&quot;;
  27.             booklist.Items.Add(classic);

  28.             // Adding child items
  29.             C1TreeViewItem subclassic = new C1TreeViewItem();
  30.             StackPanel sp1 = new StackPanel();
  31.             sp1.Orientation = Orientation.Horizontal;
  32.             sp1.Children.Add(new Image() { Width = 14, Height = 14, Source = new BitmapImage(new Uri(&quot;Resources/Book.png&quot;,UriKind.Relative)) });
  33.             sp1.Children.Add(new TextBlock() { FontSize = 11, Margin = new Thickness(4, 0, 0, 0), Text = &quot;Catch-22&quot; });
  34.             subclassic.Header = sp1;
  35.             classic.Items.Add(subclassic);

  36.             C1TreeViewItem subclassic2 = new C1TreeViewItem();
  37.             StackPanel sp2 = new StackPanel();
  38.             sp2.Orientation = Orientation.Horizontal;
  39.             sp2.Children.Add(new Image() { Width = 14, Height = 14, Source = new BitmapImage(new Uri(&quot;Resources/Book.png&quot;, UriKind.Relative)) });
  40.             sp2.Children.Add(new TextBlock() { FontSize = 11, Margin = new Thickness(4, 0, 0, 0), Text = &quot;The Great Gatsby&quot; });
  41.             subclassic2.Header = sp2;
  42.             classic.Items.Add(subclassic2);
  43.         }
  44.     }
复制代码



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部