コード例 #1
0
        public ListSystemParameters()
        {
            Title = "List System Parameters";

            ListView lstvue = new ListView();
            Content = lstvue;

            GridView grdvue = new GridView();
            lstvue.View = grdvue;

            GridViewColumn col = new GridViewColumn();
            col.Header = "Property Name";
            col.Width = 200;
            col.DisplayMemberBinding = new Binding("Name");
            grdvue.Columns.Add(col);

            col = new GridViewColumn();
            col.Header = "Value";
            col.Width = 200;
            col.DisplayMemberBinding = new Binding("Value");
            grdvue.Columns.Add(col);

            PropertyInfo[] props = typeof(SystemParameters).GetProperties();
            foreach (PropertyInfo prop in props)
            {
                if (prop.PropertyType != typeof(ResourceKey))
                {
                    SystemParam sysparam = new SystemParam();
                    sysparam.Name = prop.Name;
                    sysparam.Value = prop.GetValue(null, null);
                    lstvue.Items.Add(sysparam);
                }
            }
        }
コード例 #2
0
        public ListSortedSystemParameters()
        {
            Title = "List Sorted System Parameters";

            // Create a ListView as content of the window.
            ListView lstvue = new ListView();
            Content = lstvue;

            // Create a GridView as the View of the ListView.
            GridView grdvue = new GridView();
            lstvue.View = grdvue;

            // Create two GridView columns.
            GridViewColumn col = new GridViewColumn();
            col.Header = "Property Name";
            col.Width = 200;
            col.DisplayMemberBinding = new Binding("Name");
            grdvue.Columns.Add(col);

            col = new GridViewColumn();
            col.Header = "Value";
            col.Width = 200;
            grdvue.Columns.Add(col);

            // Create DataTemplate for second column.
            DataTemplate template = new DataTemplate(typeof(string));
            FrameworkElementFactory factoryTextBlock =
                new FrameworkElementFactory(typeof(TextBlock));
            factoryTextBlock.SetValue(TextBlock.HorizontalAlignmentProperty,
                                      HorizontalAlignment.Right);
            factoryTextBlock.SetBinding(TextBlock.TextProperty,
                                        new Binding("Value"));
            template.VisualTree = factoryTextBlock;
            col.CellTemplate = template;

            // Get all the system parameters in one handy array.
            PropertyInfo[] props = typeof(SystemParameters).GetProperties();

            // Create a SortedList to hold the SystemParam objects.
            SortedList<string, SystemParam> sortlist =
                                    new SortedList<string, SystemParam>();

            // Fill up the SortedList from the PropertyInfo array.
            foreach (PropertyInfo prop in props)
                if (prop.PropertyType != typeof(ResourceKey))
                {
                    SystemParam sysparam = new SystemParam();
                    sysparam.Name = prop.Name;
                    sysparam.Value = prop.GetValue(null, null);
                    sortlist.Add(prop.Name, sysparam);
                }

            // Set the ItemsSource property of the ListView.
            lstvue.ItemsSource = sortlist.Values;
        }
コード例 #3
0
        public ListSortedSystemParameters()
        {
            Title = "List Sorted System Parameters";

            ListView lstvue = new ListView();
            Content = lstvue;

            GridView grdvue = new GridView();
            lstvue.View = grdvue;

            GridViewColumn col = new GridViewColumn();
            col.Header = "Property Name";
            col.Width = 200;
            col.DisplayMemberBinding = new Binding("Name");
            grdvue.Columns.Add(col);

            col = new GridViewColumn();
            col.Header = "Value";
            col.Width = 200;
            grdvue.Columns.Add(col);

            DataTemplate template = new DataTemplate(typeof(string));
            FrameworkElementFactory factoryTextBlock = new FrameworkElementFactory(typeof(TextBlock));
            factoryTextBlock.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Right);
            factoryTextBlock.SetBinding(TextBlock.TextProperty, new Binding("Value"));
            template.VisualTree = factoryTextBlock;
            col.CellTemplate = template;

            PropertyInfo[] props = typeof(SystemParameters).GetProperties();
            SortedList<string, SystemParam> sortlist = new SortedList<string, SystemParam>();
            foreach (PropertyInfo prop in props)
            {
                if (prop.PropertyType != typeof(ResourceKey))
                {
                    SystemParam sysparam = new SystemParam();
                    sysparam.Name = prop.Name;
                    sysparam.Value = prop.GetValue(null, null);
                    sortlist.Add(prop.Name, sysparam);
                }
            }

            lstvue.ItemsSource = sortlist.Values;
        }
コード例 #4
0
        public ListSystemParameters()
        {
            Title = "List System Parameters";

            // Create a ListView as content of the window.
            ListView lstvue = new ListView();
            Content = lstvue;

            // Create a GridView as the View of the ListView.
            GridView grdvue = new GridView();
            lstvue.View = grdvue;

            // Create two GridView columns.
            GridViewColumn col = new GridViewColumn();
            col.Header = "Property Name";
            col.Width = 200;
            col.DisplayMemberBinding = new Binding("Name");
            grdvue.Columns.Add(col);

            col = new GridViewColumn();
            col.Header = "Value";
            col.Width = 200;
            col.DisplayMemberBinding = new Binding("Value");
            grdvue.Columns.Add(col);

            // Get all the system parameters in one handy array.
            PropertyInfo[] props = typeof(SystemParameters).GetProperties();

            // Add the items to the ListView.
            foreach (PropertyInfo prop in props)
                if (prop.PropertyType != typeof(ResourceKey))
                {
                    SystemParam sysparam = new SystemParam();
                    sysparam.Name = prop.Name;
                    sysparam.Value = prop.GetValue(null, null);
                    lstvue.Items.Add(sysparam);
                }
        }