日期:2014-05-18 浏览次数:20835 次
<Window x:Class="Test.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <TreeView Name="TV"> <TreeViewItem Header="Hello,world!"> <TreeViewItem.Resources> <Style TargetType="Border"> <Setter Property="Margin" Value="100,0,0,0"></Setter> </Style> </TreeViewItem.Resources> <TreeViewItem Header="I am sad!"></TreeViewItem> </TreeViewItem> </TreeView> </Grid> </Window>
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace Test { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); this.TV.Items.Add("I am happy!"); } } }