示例#1
0
        private ListView CreateContent(IEnumerable <ActivityLevel> items, bool useWrapPanel)
        {
            var listView = new ListView();

            foreach (var item in items)
            {
                StackPanel s = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                ////g.HorizontalAlignment = HorizontalAlignment.Stretch;

                StatusIndicator indicator = new StatusIndicator(item);
                indicator.Subscribe();
                indicator.Width  = 30;
                indicator.Height = 10;
                s.Children.Add(indicator);
                _indicators.Add(indicator);

                TextBlock label = new TextBlock();
                label.Text = item.Name;
                Grid.SetColumn(label, 1);
                s.Children.Add(label);

                s.ToolTip = item.Name;
                s.Tag     = item;

                listView.Items.Add(s);
            }

            if (useWrapPanel)
            {
                listView.SelectionMode = SelectionMode.Single;
                listView.SetValue(
                    ScrollViewer.HorizontalScrollBarVisibilityProperty,
                    ScrollBarVisibility.Disabled
                    );

                var wrapPanelFactory = new FrameworkElementFactory(typeof(WrapPanel));
                wrapPanelFactory.SetValue(WrapPanel.ItemWidthProperty, 120d);
                listView.ItemsPanel = new ItemsPanelTemplate(wrapPanelFactory);
            }

            return(listView);
        }
示例#2
0
        private ListView CreateContent(IEnumerable<ActivityLevel> items, bool useWrapPanel)
        {
            var listView = new ListView();

            foreach (var item in items)
            {
                StackPanel s = new StackPanel() { Orientation = Orientation.Horizontal };
                ////g.HorizontalAlignment = HorizontalAlignment.Stretch;

                StatusIndicator indicator = new StatusIndicator(item);
                indicator.Subscribe();
                indicator.Width = 30;
                indicator.Height = 10;
                s.Children.Add(indicator);
                this.indicators.Add(indicator);

                TextBlock label = new TextBlock();
                label.Text = item.Name;
                Grid.SetColumn(label, 1);
                s.Children.Add(label);

                s.ToolTip = item.Name;
                s.Tag = item;

                listView.Items.Add(s);
            }

            if (useWrapPanel)
            {
                listView.SelectionMode = SelectionMode.Single;
                listView.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);

                var wrapPanelFactory = new FrameworkElementFactory(typeof(WrapPanel));
                wrapPanelFactory.SetValue(WrapPanel.ItemWidthProperty, 120d);
                listView.ItemsPanel = new ItemsPanelTemplate(wrapPanelFactory);
            }

            return listView;
        }