欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
WPF中的TreeView控件_銀光中國 Silverlight 資源 社區 論壇
時(shí)間:2010-12-24 01:18來(lái)源:百度空間 作者:2sws 點(diǎn)擊:170次
TreeView繼承于HeaderedItemsControl類(lèi),而HeaderedItemsControl類(lèi)又繼承于ItemsControl類(lèi),所也TreeView同時(shí)會(huì )擁有ItemsSource屬性設置數據源;DisplayMemberPath設置數據項顯示內容;ItemContainerStyle屬性設置TreeViewItem數據項的樣式;ItemContainerStyleSelector屬性設置TreeViewItem數據項樣式選擇器;ItemsPanel屬性
  

  TreeView繼承于HeaderedItemsControl類(lèi),而HeaderedItemsControl類(lèi)又繼承于ItemsControl類(lèi),所也TreeView同時(shí)會(huì )擁有ItemsSource屬性設置數據源;DisplayMemberPath設置數據項顯示內容;ItemContainerStyle屬性設置TreeViewItem數據項的樣式;ItemContainerStyleSelector屬性設置TreeViewItem數據項樣式選擇器;ItemsPanel屬性設置數據項的容器;ItemsPanel屬性設置數據項容器的選擇器;GroupStyle屬性顯示數據分組;GroupStyleSelector屬性設置數據分組選擇器。

  與ListBoxItem不同的是每一個(gè)TreeViewItem都繼承于HeaderedItemsControl類(lèi)所以TreeViewItem是一個(gè)列表型的容器(而ListBoxItem是內容型的容器)。

  在聲明TreeViewItem的數據模板時(shí)也與ListBoxItem有所不同,它使用聲明數據模板。

  關(guān)于TreeView綁定數據,及數據模板的使用的示例代碼如下所示:

  由于在樹(shù)中顯示數據,所以使用了兩個(gè)嵌套的類(lèi)型作為實(shí)例類(lèi),兩個(gè)實(shí)體類(lèi)的代碼如下:

class MyClass:INotifyPropertyChanged
    {
        private string classname;
        private ObservableCollection<Stu> students;

        public string ClassName
        {
            get { return classname; }
            set
            {
                classname = value;
                OnPropertyChanged(new PropertyChangedEventArgs("ClassName"));
            }
        }

        public ObservableCollection<Stu> Students
        {
            get { return students; }
            set
            {
                students = value;
                OnPropertyChanged(new PropertyChangedEventArgs("Students"));
            }
        }

        #region INotifyPropertyChanged 成員
        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            if (PropertyChanged!=null)
            {
                PropertyChanged(this, e);
            }
        }
        #endregion
    }

 

    class Stu:INotifyPropertyChanged
    {

        private int myid;
        private string mynames;
        private int myage;
        private string mysex;
        private string myaddress;

        public int id
        {
            get { return myid; }
            set
            {
                myid = value;
                OnPropertyChanged(new PropertyChangedEventArgs("id"));
            }
        }

        public string names
        {
            get { return mynames; }
            set
            {
                mynames = value;
                OnPropertyChanged(new PropertyChangedEventArgs("names"));
            }
        }

        public int age
        {
            get { return myage; }
            set
            {
                myage = value;
                OnPropertyChanged(new PropertyChangedEventArgs("age"));
            }
        }

        public string sex
        {
            get { return mysex; }
            set
            {
                mysex = value;
                OnPropertyChanged(new PropertyChangedEventArgs("sex"));
            }
        }

        public string address
        {
            get { return myaddress; }
            set
            {
                myaddress = value;
                OnPropertyChanged(new PropertyChangedEventArgs("address"));
            }
        }

 

        #region INotifyPropertyChanged 成員

        public event PropertyChangedEventHandler PropertyChanged;

        public void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, e);
            }
        }

        #endregion
    }

 資源字典的XAML代碼如下所示:

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="WPF中的TreeView控件.MyDictionary"
    xmlns:local="clr-namespace:WPF中的TreeView控件">
    
    <ObjectDataProvider x:Key="MyDataBase"
                        ObjectType="{x:Type local:wangjundatabase}"
                        MethodName="GetAllStu"
                        IsAsynchronous="True">
    </ObjectDataProvider>
    
    <HierarchicalDataTemplate x:Key="treeviewtemplate"ItemsSource="{Binding Path=Students}">
        <Grid Background="White">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" SharedSizeGroup="abc"/>
            </Grid.ColumnDefinitions>
            <Border Margin="2"
                CornerRadius="3"
                Background="DarkGoldenrod">
                <StackPanel>
                    <TextBlock Text="{Binding Path=ClassName}" Margin="5"></TextBlock>
                </StackPanel>
            </Border>
        </Grid>
        <HierarchicalDataTemplate.ItemTemplate>
           <HierarchicalDataTemplate>
                <Grid Background="White">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" SharedSizeGroup="abcd"/>
                    </Grid.ColumnDefinitions>
                    <Border Margin="2"
                                    CornerRadius="3"
                                    Background="Chocolate">
                        <StackPanel>
                            <TextBlock Text="{Binding Path=id}" Margin="5,1,5,1"></TextBlock>
                            <TextBlock Text="{Binding Path=names}" Margin="5,1,5,1"></TextBlock>
                            <TextBlock Text="{Binding Path=age}" Margin="5,1,5,1"></TextBlock>
                            <TextBlock Text="{Binding Path=sex}" Margin="5,1,5,1"></TextBlock>
                            <TextBlock Text="{Binding Path=address}" Margin="5,1,5,1"></TextBlock>
                        </StackPanel>
                    </Border>
                </Grid>               
           </HierarchicalDataTemplate>
        </HierarchicalDataTemplate.ItemTemplate>
    </HierarchicalDataTemplate>
    
</ResourceDictionary>

  窗體XAML代碼如下所示:

<Window x:Class="WPF中的TreeView控件.Window1"
    xmlns=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x=
"http://schemas.microsoft.com/winfx/2006/xaml"
    Title=
"Window1" Height="600" Width="600" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/MyDictionary/MyDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <TreeView Margin="10" ItemTemplate="{StaticResource treeviewtemplate}"
                  ItemsSource=
"{Binding Source={StaticResource MyDataBase}}"
                  SnapsToDevicePixels=
"True" Grid.IsSharedSizeScope="True">
            <TreeView.ItemContainerStyle>
                <Style TargetType="TreeViewItem">
                    <Setter Property="Padding" Value="0"/>
                </Style>
            </TreeView.ItemContainerStyle>
        </TreeView>
    </Grid>
</Window>

本文來(lái)自2sws的博客,原文地址:http://hi.baidu.com/wangjunwangjuna/blog/item/0cb1de16977f7509962b4320.html

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
WPF快速入門(mén)系列(7)
用WPF建的IPAD demo (內附下載源碼)
WPF深入淺出話(huà)資源
C# WPF抽屜效果實(shí)現(C# WPF Material Design UI: Navigation Drawer & PopUp Menu)
WPF開(kāi)發(fā)學(xué)生信息管理系統【W(wǎng)PF+Prism+MAH+WebApi】(一)
定義和使用字典資源
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久