상속: System.Windows.Controls.ListView
예제 #1
0
        // Static method called when TypeProperty changes.
        static void OnTypePropertyChanged(DependencyObject obj,
                                          DependencyPropertyChangedEventArgs args)
        {
            // Get the ListView object involved.
            DependencyPropertyListView lstvue = obj as DependencyPropertyListView;

            // Get the new value of the Type property.
            Type type = args.NewValue as Type;

            // Get rid of all the items currently stored by the ListView.
            lstvue.ItemsSource = null;

            // Get all the DependencyProperty fields in the Type object.
            if (type != null)
            {
                SortedList <string, DependencyProperty> list =
                    new SortedList <string, DependencyProperty>();
                FieldInfo[] infos = type.GetFields();

                foreach (FieldInfo info in infos)
                {
                    if (info.FieldType == typeof(DependencyProperty))
                    {
                        list.Add(info.Name,
                                 (DependencyProperty)info.GetValue(null));
                    }
                }

                // Set the ItemsSource to the list.
                lstvue.ItemsSource = list.Values;
            }
        }
예제 #2
0
        public ExploreDependencyProperties()
        {
            Title = "Explore Dependency Properties";

            // Create Grid as content of window.
            Grid grid = new Grid();

            Content = grid;

            // Three column definitions for Grid.
            ColumnDefinition col = new ColumnDefinition();

            col.Width = new GridLength(1, GridUnitType.Star);
            grid.ColumnDefinitions.Add(new ColumnDefinition());

            col       = new ColumnDefinition();
            col.Width = GridLength.Auto;
            grid.ColumnDefinitions.Add(col);

            col       = new ColumnDefinition();
            col.Width = new GridLength(3, GridUnitType.Star);
            grid.ColumnDefinitions.Add(col);

            // ClassHierarchyTreeView goes on left side.
            ClassHierarchyTreeView treevue =
                new ClassHierarchyTreeView(typeof(DependencyObject));

            grid.Children.Add(treevue);
            Grid.SetColumn(treevue, 0);

            // GridSplitter goes in the center cell.
            GridSplitter split = new GridSplitter();

            split.HorizontalAlignment = HorizontalAlignment.Center;
            split.VerticalAlignment   = VerticalAlignment.Stretch;
            split.Width = 6;
            grid.Children.Add(split);
            Grid.SetColumn(split, 1);

            // DependencyPropertyListView goes on right side.
            DependencyPropertyListView lstvue = new DependencyPropertyListView();

            grid.Children.Add(lstvue);
            Grid.SetColumn(lstvue, 2);

            // Set a binding between TreeView and ListView.
            lstvue.SetBinding(DependencyPropertyListView.TypeProperty,
                              "SelectedItem.Type");
            lstvue.DataContext = treevue;
        }
        public ExploreDependencyProperties()
        {
            Title = "Explore Dependency Properties";

            // Create Grid as content of window.
            Grid grid = new Grid();
            Content = grid;

            // Three column definitions for Grid.
            ColumnDefinition col = new ColumnDefinition();
            col.Width = new GridLength(1, GridUnitType.Star);
            grid.ColumnDefinitions.Add(new ColumnDefinition());

            col = new ColumnDefinition();
            col.Width = GridLength.Auto;
            grid.ColumnDefinitions.Add(col);

            col = new ColumnDefinition();
            col.Width = new GridLength(3, GridUnitType.Star);
            grid.ColumnDefinitions.Add(col);

            // ClassHierarchyTreeView goes on left side.
            ClassHierarchyTreeView treevue =
                            new ClassHierarchyTreeView(typeof(DependencyObject));
            grid.Children.Add(treevue);
            Grid.SetColumn(treevue, 0);

            // GridSplitter goes in the center cell.
            GridSplitter split = new GridSplitter();
            split.HorizontalAlignment = HorizontalAlignment.Center;
            split.VerticalAlignment = VerticalAlignment.Stretch;
            split.Width = 6;
            grid.Children.Add(split);
            Grid.SetColumn(split, 1);

            // DependencyPropertyListView goes on right side.
            DependencyPropertyListView lstvue = new DependencyPropertyListView();
            grid.Children.Add(lstvue);
            Grid.SetColumn(lstvue, 2);

            // Set a binding between TreeView and ListView.
            lstvue.SetBinding(DependencyPropertyListView.TypeProperty,
                              "SelectedItem.Type");
            lstvue.DataContext = treevue;
        }
        public ExploreDependencyProperties()
        {
            Title = "Explore Dependency Properties";

            Grid grid = new Grid();

            Content = grid;

            ColumnDefinition col = new ColumnDefinition();

            col.Width = new GridLength(1, GridUnitType.Star);
            grid.ColumnDefinitions.Add(col);

            col       = new ColumnDefinition();
            col.Width = GridLength.Auto;
            grid.ColumnDefinitions.Add(col);

            col       = new ColumnDefinition();
            col.Width = new GridLength(3, GridUnitType.Star);
            grid.ColumnDefinitions.Add(col);

            ClassHierarchyTreeView treevue = new ClassHierarchyTreeView(typeof(DependencyObject));

            grid.Children.Add(treevue);
            Grid.SetColumn(treevue, 0);

            GridSplitter split = new GridSplitter();

            split.HorizontalAlignment = HorizontalAlignment.Center;
            split.VerticalAlignment   = VerticalAlignment.Stretch;
            split.Width = 6;
            grid.Children.Add(split);
            Grid.SetColumn(split, 1);

            DependencyPropertyListView lstvue = new DependencyPropertyListView();

            grid.Children.Add(lstvue);
            Grid.SetColumn(lstvue, 2);

            lstvue.SetBinding(DependencyPropertyListView.TypeProperty, "SelectedItem.Type");
            lstvue.DataContext = treevue;
        }
예제 #5
0
        static void OnTypePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            DependencyPropertyListView lstvue = obj as DependencyPropertyListView;
            Type type = args.NewValue as Type;

            lstvue.ItemsSource = null;
            if (type != null)
            {
                SortedList <string, DependencyProperty> list = new SortedList <string, DependencyProperty>();
                FieldInfo[] infos = type.GetFields();
                foreach (FieldInfo info in infos)
                {
                    if (info.FieldType == typeof(DependencyProperty))
                    {
                        list.Add(info.Name, (DependencyProperty)info.GetValue(null));
                    }
                }
                lstvue.ItemsSource = list.Values;
            }
        }
        public ExploreDependencyProperties()
        {
            Title = "Explore Dependency Properties";

            Grid grid = new Grid();
            Content = grid;

            ColumnDefinition col = new ColumnDefinition();
            col.Width = new GridLength(1, GridUnitType.Star);
            grid.ColumnDefinitions.Add(col);

            col = new ColumnDefinition();
            col.Width = GridLength.Auto;
            grid.ColumnDefinitions.Add(col);

            col = new ColumnDefinition();
            col.Width = new GridLength(3, GridUnitType.Star);
            grid.ColumnDefinitions.Add(col);

            ClassHierarchyTreeView treevue = new ClassHierarchyTreeView(typeof(DependencyObject));
            grid.Children.Add(treevue);
            Grid.SetColumn(treevue, 0);

            GridSplitter split = new GridSplitter();
            split.HorizontalAlignment = HorizontalAlignment.Center;
            split.VerticalAlignment = VerticalAlignment.Stretch;
            split.Width = 6;
            grid.Children.Add(split);
            Grid.SetColumn(split, 1);

            DependencyPropertyListView lstvue = new DependencyPropertyListView();
            grid.Children.Add(lstvue);
            Grid.SetColumn(lstvue, 2);

            lstvue.SetBinding(DependencyPropertyListView.TypeProperty, "SelectedItem.Type");
            lstvue.DataContext = treevue;
        }