1. <Window x:Class="控件Demo.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
  5. Title="控件学习" Height="350" Width="525"
  6. xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
  7. <Grid ShowGridLines="True">
  8. <Menu HorizontalAlignment="Left" Name="menu1" VerticalAlignment="Top" IsMainMenu="True" ItemsSource="{Binding}" Background="#00000000">
  9. <MenuItem Header="文件">
  10. <MenuItem Header="Copy" Click="MenuItem_Click"/>
  11. <MenuItem Header="Cut" />
  12. <MenuItem Header="Paste" />
  13. </MenuItem>
  14. <MenuItem Header="帮助" StaysOpenOnClick="True">
  15. <MenuItem Header="About" />
  16. </MenuItem>
  17. </Menu>
  18. <Expander Header="expander1" Height="100" HorizontalAlignment="Left" Margin="48,76,0,0" Name="expander1" VerticalAlignment="Top">
  19. <Expander.ContextMenu>
  20. <ContextMenu>
  21. <MenuItem Header="删除" />
  22. <MenuItem Header="添加" />
  23. </ContextMenu>
  24. </Expander.ContextMenu>
  25. <Grid ShowGridLines="True">
  26. <Grid.RowDefinitions>
  27. <RowDefinition />
  28. <RowDefinition />
  29. <RowDefinition />
  30. </Grid.RowDefinitions>
  31. <Grid.ColumnDefinitions>
  32. <ColumnDefinition/>
  33. <ColumnDefinition/>
  34. <ColumnDefinition/>
  35. </Grid.ColumnDefinitions>
  36. </Grid>
  37. </Expander>
  38. <StatusBar HorizontalAlignment="Left" Name="statusBar1" VerticalAlignment="Bottom" Background="#00000000">
  39. <StatusBarItem HorizontalAlignment="Left" Content="公有N个测试项,当前正在测试N-2项" />
  40. </StatusBar>
  41. <ToolBar HorizontalAlignment="Left" Margin="0,27,0,0" Name="toolBar1" VerticalAlignment="Top" >
  42. <Button Content="btnTest"/>
  43. <Label Content="lblTest"/>
  44. <ComboBox SelectedIndex="0">
  45. <ComboBoxItem>100%</ComboBoxItem>
  46. <ComboBoxItem>150%</ComboBoxItem>
  47. <ComboBoxItem>200%</ComboBoxItem>
  48. </ComboBox>
  49. </ToolBar>
  50.  
  51. <WindowsFormsHost HorizontalAlignment="Left" Width="75" Height="30" Margin="205,27,0,0" Name="windowsFormsHost1" VerticalAlignment="Top" >
  52. <wf:Button Text="test" Click="Button_Click" />
  53. </WindowsFormsHost>
  54.  
  55. <telerik:RadTreeListView
  56. telerik:StyleManager.Theme="Office_Silver"
  57. AutoGenerateColumns="False"
  58. IsFilteringAllowed="False"
  59. HierarchyColumnIndex="0"
  60. RowIndicatorVisibility="Collapsed"
  61. Name="tlvList"
  62. IsReadOnly="True" Margin="12,182,12,28">
  63. <telerik:RadTreeListView.ChildTableDefinitions>
  64. <telerik:TreeListViewTableDefinition ItemsSource="{Binding Child}" />
  65. </telerik:RadTreeListView.ChildTableDefinitions>
  66. <telerik:RadTreeListView.Columns>
  67. <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="名称" Width="150" >
  68. </telerik:GridViewDataColumn>
  69. <telerik:GridViewDataColumn DataMemberBinding="{Binding CreateDate}" Header="创建时间" Width="150" />
  70. <telerik:GridViewDataColumn DataMemberBinding="{Binding Version}" Header="版本" Width="150" />
  71. </telerik:RadTreeListView.Columns>
  72. </telerik:RadTreeListView>
  73.  
  74. <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="361,62,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
  75. </Grid>
  76. </Window>
  77.  
  78. <Window x:Class="控件Demo.Window1"
  79. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  80. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  81. xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
  82. Title="Window1" Height="300" Width="500">
  83. <Grid>
  84. <telerik:RadTreeListView
  85. telerik:StyleManager.Theme="Office_Silver"
  86. AutoGenerateColumns="False"
  87. IsFilteringAllowed="False"
  88. HierarchyColumnIndex="0"
  89. RowIndicatorVisibility="Collapsed"
  90. Name="tv"
  91. IsReadOnly="True" >
  92. <telerik:RadTreeListView.ChildTableDefinitions>
  93. <telerik:TreeListViewTableDefinition ItemsSource="{Binding Child}" />
  94. </telerik:RadTreeListView.ChildTableDefinitions>
  95. <telerik:RadTreeListView.Columns>
  96. <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="名称" Width="150" >
  97. </telerik:GridViewDataColumn>
  98. <telerik:GridViewDataColumn DataMemberBinding="{Binding CreateDate}" Header="创建时间" Width="150" />
  99. <telerik:GridViewDataColumn DataMemberBinding="{Binding Version}" Header="版本" Width="150" />
  100. </telerik:RadTreeListView.Columns>
  101. </telerik:RadTreeListView>
  102. </Grid>
  103. </Window>
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace 控件Demo
  7. {
  8. public class Helper
  9. {
  10. private static Helper instance;
  11. public static Helper Instance
  12. {
  13. get
  14. {
  15. if (instance == null) instance = new Helper();
  16. return Helper.instance;
  17. }
  18. }
  19. /// <summary>
  20. /// 工程列表信息
  21. /// </summary>
  22. /// <returns></returns>
  23. public List<ProjectConfigModel> GetProjectList()
  24. {
  25. List<ProjectConfigModel> list = new List<ProjectConfigModel>();
  26.  
  27. ProjectConfigModel devRoot = new ProjectConfigModel
  28. {
  29. Name = "开发组A",
  30. CreateDate = string.Empty,
  31. Version = string.Empty,
  32. Child = new List<ProjectConfigModel>(),
  33. };
  34. devRoot.Child.Add(new ProjectConfigModel
  35. {
  36. Name = "孙001",
  37. CreateDate = "2014.05.15 11:11:11",
  38. Version = "V2.0.0.1"
  39. });
  40. devRoot.Child.Add(new ProjectConfigModel
  41. {
  42. Name = "张111",
  43. CreateDate = "2014.05.15 12:11:11",
  44. Version = "V2.0.0.2"
  45. });
  46. devRoot.Child.Add(new ProjectConfigModel
  47. {
  48. Name = "周001",
  49. CreateDate = "2014.05.15 13:11:11",
  50. Version = "V2.0.0.3"
  51. });
  52. devRoot.Child.Add(new ProjectConfigModel
  53. {
  54. Name = "张01",
  55. CreateDate = "2014.05.15 14:11:11",
  56. Version = "V2.0.0.4"
  57. });
  58. devRoot.Child.Add(new ProjectConfigModel
  59. {
  60. Name = "曹001",
  61. CreateDate = "2014.05.15 15:11:11",
  62. Version = "V2.0.0.5"
  63. });
  64. list.Add(devRoot);
  65.  
  66. ProjectConfigModel testRoot = new ProjectConfigModel
  67. {
  68. Name = "测试组A",
  69. CreateDate = string.Empty,
  70. Version = string.Empty,
  71. Child = new List<ProjectConfigModel>(),
  72. };
  73. testRoot.Child.Add(new ProjectConfigModel
  74. {
  75. Name = "慕001",
  76. CreateDate = "2014.05.15 11:11:11",
  77. Version = "V2.0.0.1"
  78. });
  79. testRoot.Child.Add(new ProjectConfigModel
  80. {
  81. Name = "陈001",
  82. CreateDate = "2014.05.15 12:11:11",
  83. Version = "V2.0.0.2"
  84. });
  85. testRoot.Child.Add(new ProjectConfigModel
  86. {
  87. Name = "张xx",
  88. CreateDate = "2014.05.15 13:11:11",
  89. Version = "V2.0.0.3"
  90. });
  91. testRoot.Child.Add(new ProjectConfigModel
  92. {
  93. Name = "李xx",
  94. CreateDate = "2014.05.15 14:11:11",
  95. Version = "V2.0.0.4"
  96. });
  97. testRoot.Child.Add(new ProjectConfigModel
  98. {
  99. Name = "zhoumm",
  100. CreateDate = "2014.05.15 15:11:11",
  101. Version = "V2.0.0.5"
  102. });
  103. list.Add(testRoot);
  104.  
  105. return list;
  106. }
  107. }
  108. }
  109.  
  110. using System;
  111. using System.Windows;
  112.  
  113. namespace 控件Demo
  114. {
  115. /// <summary>
  116. /// MainWindow.xaml 的交互逻辑
  117. /// </summary>
  118. public partial class MainWindow : Window
  119. {
  120. public MainWindow()
  121. {
  122. InitializeComponent();
  123.  
  124. this.tlvList.ItemsSource = Helper.Instance.GetProjectList();
  125. }
  126.  
  127. private void MenuItem_Click(object sender, RoutedEventArgs e)
  128. {
  129. MessageBox.Show("Copy");
  130. }
  131.  
  132. private void Button_Click(object sender, EventArgs e)
  133. {
  134. Form1 f = new Form1();
  135. f.Show();
  136. }
  137.  
  138. private void button1_Click(object sender, RoutedEventArgs e)
  139. {
  140. Window1 w = new Window1();
  141. w.Show();
  142. }
  143. }
  144. }
  145.  
  146. using System.Windows;
  147.  
  148. namespace 控件Demo
  149. {
  150. /// <summary>
  151. /// Window1.xaml 的交互逻辑
  152. /// </summary>
  153. public partial class Window1 : Window
  154. {
  155. public Window1()
  156. {
  157. InitializeComponent();
  158.  
  159. this.tv.ItemsSource = Helper.Instance.GetProjectList();
  160. }
  161. }
  162. }

运行效果:

WPF Demo10 嵌套Winform、RadGridView、的更多相关文章

  1. 在WPF中使用WinForm控件方法

    1.      首先添加对如下两个dll文件的引用:WindowsFormsIntegration.dll,System.Windows.Forms.dll. 2.      在要使用WinForm控 ...

  2. 在WPF中调用Winform控件

    最近在项目中用到了人脸识别和指纹识别,需要调用外部设备和接口,这里就用到了在WPF中调用Winform控件. 第一步,添加程序集引用.System.Windows.Forms和WindowsForms ...

  3. [转]在WPF中使用WinForm控件方法

    本文转自:http://blog.csdn.net/lianchangshuai/article/details/6415241 下面以在Wpf中添加ZedGraph(用于创建任意数据的二维线型.条型 ...

  4. WPF加载Winform窗体时 报错:子控件不能为顶级窗体

    一.wpf项目中引用WindowsFormsIntegration和System.Windows.Forms 二.Form1.Designer.cs 的 partial class Form1 设置为 ...

  5. WPF中嵌入WinForm中的webbrowser控件

    原文:WPF中嵌入WinForm中的webbrowser控件 使用VS2008创建WPF应用程序,需使用webbrowser.从工具箱中添加WPF组件中的webbrowser发现其中有很多属性事件不能 ...

  6. WPF保存包含Winform控件的XAML页面问题

    原文:WPF保存包含Winform控件的XAML页面问题 最近的工作中,用到了WPF调用Winform控件 但是在保存XAML页面的时候发现了问题,就是Winform页面黑黑的,没有任何渲染的波形曲线 ...

  7. WPF中添加Winform用户自定义控件

    过程:创建WPF工程->创建Winform用户自定义控件工程->WPF中引用控件->添加到Xaml页面 1.首先在WPF工程的解决方案上右击选择添加新建项目: 选择Windows窗体 ...

  8. Wpf使用Winform控件后Wpf元素被Winform控件遮盖问题的解决

    有人会说不建议Wpf中使用Winform控件,有人会说建议使用Winform控件在Wpf下的替代方案,然而在实际工作中由于项目的特殊需求,考虑到时间.成本等因素,往往难免会碰到在WPF中使用Winfr ...

  9. WPF 精修篇 Winform 嵌入WPF控件

    原文:WPF 精修篇 Winform 嵌入WPF控件 首先 创建WPF控件库 这样就有了一个WPF界面 在wpf中增加界面等 在winform中增加WPFDLL 重新生成解决方案 在左侧工具栏 出现W ...

随机推荐

  1. 小程序数组型图片自适应效果的实现(交流QQ群:604788754)

    //本例代码如有问题,请加群,下载今日日期文件,测试.(如对本例有疑问,也可加群咨询群主) WXML: <view class="imgbox"> <block ...

  2. SQL Server 调优系列基础篇 - 子查询运算总结

    前言 前面我们的几篇文章介绍了一系列关于运算符的介绍,以及各个运算符的优化方式和技巧.其中涵盖:查看执行计划的方式.几种数据集常用的连接方式.联合运算符方式.并行运算符等一系列的我们常见的运算符.有兴 ...

  3. oracle_sql语句的大全

    # 建立数据库struts   CREATE DATABASE IF NOT EXISTS struts DEFAULT CHARACTER SET GBK; 1.登录:(管理员)conn sys/p ...

  4. 团队NABCD

    NABCD 你的创意解决了用户的什么需求?(N) 每学期开学同学们都有相同的困难:我该选哪几门课?这门课到底是做什么的?有时候上一届的学长学姐会告诉我们他们觉得好的课,但这并不全面.所以我们需要一个平 ...

  5. flask+APScheduler 任务调度,计划任务,定时任务

    from flask import Flask from flask_apscheduler import APScheduler # 引入APScheduler from test124 impor ...

  6. Java——多线程练习

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...

  7. AngularJS-----$compile

    原文:http://docs.ngnice.com/api/ng/service/$compile 写在前面的话: 之前我一直理解错误,我一直以为这句--function([scope], clone ...

  8. L233

    Betty was offended because she felt that her friends had ignored her purposefully(deliberately) at t ...

  9. 逆向路由器固件之SQL注入 Part3

    另寻他径 在前面的内容中,我们使用TEW-654TR路由器的tftp服务实现了获取目标的管理权限.但是要是tftp没有开放到外网怎么办?另寻他径:在这一篇中会我们来分析一个web应用上的漏洞. 初步分 ...

  10. jenkins系列(11)-自动打tag升级篇

    很久以前,小怪分享过一篇jenkins自动打tag的文章(jenkins系列1--自动打tag),经过在项目实战和改进,我们升级了方案,现在和大家分享.,希望大家在工作中能够用起来. 使用步骤: 1. ...