<Window x:Class="控件Demo.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" Title="控件学习" Height="350" Width="525" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"> <Grid ShowGridLines="True"> <Menu HorizontalAlignment="Left" Name="menu1" VerticalAlignment="Top" IsMainMenu="True" ItemsSource="{Binding}" Background="#00000000"> <MenuItem Header="文件"> <MenuItem Header="Copy" Click="MenuItem_Click"/> <MenuItem Header="Cut" /> <MenuItem Header="Paste" /> </MenuItem> <MenuItem Header="帮助" StaysOpenOnClick="True"> <MenuItem Header="About" /> </MenuItem> </Menu> <Expander Header="expander1" Height="100" HorizontalAlignment="Left" Margin="48,76,0,0" Name="expander1" VerticalAlignment="Top"> <Expander.ContextMenu> <ContextMenu> <MenuItem Header="删除" /> <MenuItem Header="添加" /> </ContextMenu> </Expander.ContextMenu> <Grid ShowGridLines="True"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> </Grid> </Expander> <StatusBar HorizontalAlignment="Left" Name="statusBar1" VerticalAlignment="Bottom" Background="#00000000"> <StatusBarItem HorizontalAlignment="Left" Content="公有N个测试项,当前正在测试N-2项" /> </StatusBar> <ToolBar HorizontalAlignment="Left" Margin="0,27,0,0" Name="toolBar1" VerticalAlignment="Top" > <Button Content="btnTest"/> <Label Content="lblTest"/> <ComboBox SelectedIndex="0"> <ComboBoxItem>100%</ComboBoxItem> <ComboBoxItem>150%</ComboBoxItem> <ComboBoxItem>200%</ComboBoxItem> </ComboBox> </ToolBar> <WindowsFormsHost HorizontalAlignment="Left" Width="75" Height="30" Margin="205,27,0,0" Name="windowsFormsHost1" VerticalAlignment="Top" > <wf:Button Text="test" Click="Button_Click" /> </WindowsFormsHost> <telerik:RadTreeListView telerik:StyleManager.Theme="Office_Silver" AutoGenerateColumns="False" IsFilteringAllowed="False" HierarchyColumnIndex="0" RowIndicatorVisibility="Collapsed" Name="tlvList" IsReadOnly="True" Margin="12,182,12,28"> <telerik:RadTreeListView.ChildTableDefinitions> <telerik:TreeListViewTableDefinition ItemsSource="{Binding Child}" /> </telerik:RadTreeListView.ChildTableDefinitions> <telerik:RadTreeListView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="名称" Width="150" > </telerik:GridViewDataColumn> <telerik:GridViewDataColumn DataMemberBinding="{Binding CreateDate}" Header="创建时间" Width="150" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding Version}" Header="版本" Width="150" /> </telerik:RadTreeListView.Columns> </telerik:RadTreeListView> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="361,62,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> </Grid> </Window> <Window x:Class="控件Demo.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="Window1" Height="300" Width="500"> <Grid> <telerik:RadTreeListView telerik:StyleManager.Theme="Office_Silver" AutoGenerateColumns="False" IsFilteringAllowed="False" HierarchyColumnIndex="0" RowIndicatorVisibility="Collapsed" Name="tv" IsReadOnly="True" > <telerik:RadTreeListView.ChildTableDefinitions> <telerik:TreeListViewTableDefinition ItemsSource="{Binding Child}" /> </telerik:RadTreeListView.ChildTableDefinitions> <telerik:RadTreeListView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="名称" Width="150" > </telerik:GridViewDataColumn> <telerik:GridViewDataColumn DataMemberBinding="{Binding CreateDate}" Header="创建时间" Width="150" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding Version}" Header="版本" Width="150" /> </telerik:RadTreeListView.Columns> </telerik:RadTreeListView> </Grid> </Window>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 控件Demo { public class Helper { private static Helper instance; public static Helper Instance { get { if (instance == null ) instance = new Helper(); return Helper.instance; } } /// <summary> /// 工程列表信息 /// </summary> /// <returns></returns> public List<ProjectConfigModel> GetProjectList() { List<ProjectConfigModel> list = new List<ProjectConfigModel>(); ProjectConfigModel devRoot = new ProjectConfigModel { Name = "开发组A" , CreateDate = string .Empty, Version = string .Empty, Child = new List<ProjectConfigModel>(), }; devRoot.Child.Add( new ProjectConfigModel { Name = "孙001" , CreateDate = "2014.05.15 11:11:11" , Version = "V2.0.0.1" }); devRoot.Child.Add( new ProjectConfigModel { Name = "张111" , CreateDate = "2014.05.15 12:11:11" , Version = "V2.0.0.2" }); devRoot.Child.Add( new ProjectConfigModel { Name = "周001" , CreateDate = "2014.05.15 13:11:11" , Version = "V2.0.0.3" }); devRoot.Child.Add( new ProjectConfigModel { Name = "张01" , CreateDate = "2014.05.15 14:11:11" , Version = "V2.0.0.4" }); devRoot.Child.Add( new ProjectConfigModel { Name = "曹001" , CreateDate = "2014.05.15 15:11:11" , Version = "V2.0.0.5" }); list.Add(devRoot); ProjectConfigModel testRoot = new ProjectConfigModel { Name = "测试组A" , CreateDate = string .Empty, Version = string .Empty, Child = new List<ProjectConfigModel>(), }; testRoot.Child.Add( new ProjectConfigModel { Name = "慕001" , CreateDate = "2014.05.15 11:11:11" , Version = "V2.0.0.1" }); testRoot.Child.Add( new ProjectConfigModel { Name = "陈001" , CreateDate = "2014.05.15 12:11:11" , Version = "V2.0.0.2" }); testRoot.Child.Add( new ProjectConfigModel { Name = "张xx" , CreateDate = "2014.05.15 13:11:11" , Version = "V2.0.0.3" }); testRoot.Child.Add( new ProjectConfigModel { Name = "李xx" , CreateDate = "2014.05.15 14:11:11" , Version = "V2.0.0.4" }); testRoot.Child.Add( new ProjectConfigModel { Name = "zhoumm" , CreateDate = "2014.05.15 15:11:11" , Version = "V2.0.0.5" }); list.Add(testRoot); return list; } } } using System; using System.Windows; namespace 控件Demo { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); this .tlvList.ItemsSource = Helper.Instance.GetProjectList(); } private void MenuItem_Click( object sender, RoutedEventArgs e) { MessageBox.Show( "Copy" ); } private void Button_Click( object sender, EventArgs e) { Form1 f = new Form1(); f.Show(); } private void button1_Click( object sender, RoutedEventArgs e) { Window1 w = new Window1(); w.Show(); } } } using System.Windows; namespace 控件Demo { /// <summary> /// Window1.xaml 的交互逻辑 /// </summary> public partial class Window1 : Window { public Window1() { InitializeComponent(); this .tv.ItemsSource = Helper.Instance.GetProjectList(); } } } |
运行效果:
博客内容主要用于日常学习记录,内容比较随意,如有问题,还需谅解!!!
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core GC计划阶段(plan_phase)底层原理浅谈
· .NET开发智能桌面机器人:用.NET IoT库编写驱动控制两个屏幕
· 用纯.NET开发并制作一个智能桌面机器人:从.NET IoT入门开始
· 一个超经典 WinForm,WPF 卡死问题的终极反思
· ASP.NET Core - 日志记录系统(二)
· 支付宝事故这事儿,凭什么又是程序员背锅?有没有可能是这样的...
· 在线客服系统 QPS 突破 240/秒,连接数突破 4000,日请求数接近1000万次,.NET 多
· C# 开发工具Visual Studio 介绍
· 在 Windows 10 上实现免密码 SSH 登录
· C#中如何使用异步编程