Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="iFactr.UI.ListView&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="model">The model containing the information that is displayed by the view.</param>
        /// <param name="style">The style in which the view should be rendered.</param>
        public ListView(T model, ListViewStyle style)
        {
            Pair = MXContainer.Resolve <IListView>(style);

            NativeView.CellRequested            = OnCellRequested;
            NativeView.ItemIdRequested          = OnItemIdRequested;
            NativeView.ShouldNavigate           = ShouldNavigateFrom;
            NativeView.SeparatorColor           = iApp.Instance.Style.SeparatorColor;
            NativeView.PopoverPresentationStyle = PopoverPresentationStyle.Normal;

            Model = model;
        }
Example #2
0
        public ListView(ListViewStyle style)
        {
            InitializeComponent();
            Style = style;

            Sections         = new SectionCollection();
            ValidationErrors = new ValidationErrorCollection();
            submitValues     = new Dictionary <string, string>();

            measuringBlock = new TextBlock()
            {
                TextWrapping = TextWrapping.Wrap
            };

            container = new System.Windows.Controls.Grid()
            {
                ColumnDefinitions = { new ColumnDefinition()
                                      {
                                          Width = new GridLength(1, GridUnitType.Star)
                                      } }
            };
            Children.Add(container);

            firstColumnItems = new ListBox()
            {
                BorderThickness            = new Thickness(0),
                HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch,
                ItemContainerStyle         = (Style)Resources["ListBoxItemStyle"],
                ItemTemplateSelector       = new CellTemplateSelector(this),
                IsEnabled = false
            };

            firstColumnItems.SizeChanged += (o, e) =>
            {
                ReloadSections();
            };

            KeyboardNavigation.SetTabNavigation(firstColumnItems, KeyboardNavigationMode.Continue);
            ScrollViewer.SetHorizontalScrollBarVisibility(firstColumnItems, ScrollBarVisibility.Disabled);
            container.Children.Add(firstColumnItems);

            Loaded += (o, e) =>
            {
                if (!firstColumnItems.IsEnabled)
                {
                    firstColumnItems.IsEnabled = true;

                    var scroller = firstColumnItems.FindChild <ScrollViewer>(null);
                    if (scroller != null)
                    {
                        scroller.ScrollChanged += (obj, args) =>
                        {
                            var handler = Scrolled;
                            if (handler != null)
                            {
                                handler(Pair ?? this, EventArgs.Empty);
                            }
                        };
                    }

                    ReloadSections();

                    // the dispatcher call may look weird, but without it, animated ScrollToCell calls that happen on Render put the list in the wrong position
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        var scrollPosition = Metadata.Get <object[]>("wpfInitialScrollPosition");
                        if (scrollPosition != null)
                        {
                            Metadata.Remove("wpfInitialScrollPosition");
                            ScrollToCell((int)scrollPosition[0], (int)scrollPosition[1], (bool)scrollPosition[2]);
                        }
                    }));
                }
            };
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="iFactr.UI.ListView&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="style">The style in which the view should be rendered.</param>
 public ListView(ListViewStyle style)
     : this(default(T), style)
 {
 }
Example #4
0
 public ListViewFragment(ListViewStyle style)
 {
     Sections = new SectionCollection();
     Style    = style;
 }
Example #5
0
 public List(ListViewStyle style)
     : this()
 {
     Style = style;
 }
Example #6
0
        //----------------------------------------------------------------------
        public ListView(Screen _screen)
            : base(_screen)
        {
            Columns = new List <ListViewColumn>();

            Rows = new ObservableList <ListViewRow>();

            Rows.ListCleared += delegate {
                SelectedRow = null;
                HoveredRow  = null;
                FocusedRow  = null;

                mHoveredActionButton        = null;
                mbIsHoveredActionButtonDown = false;
            };

            Rows.ListChanged += delegate(object _source, ObservableList <ListViewRow> .ListChangedEventArgs _args)
            {
                if (!_args.Added)
                {
                    if (_args.Item == SelectedRow)
                    {
                        SelectedRow = null;
                    }

                    if (_args.Item == HoveredRow)
                    {
                        UpdateHoveredRow();
                    }

                    if (_args.Item == FocusedRow)
                    {
                        FocusedRow = null;
                        IsDragging = false;
                    }
                }
            };

            SelectedRow = null;
            FocusedRow  = null;
            HoveredRow  = null;
            TextColor   = Screen.Style.DefaultTextColor;

            Padding = Screen.Style.ListViewPadding;
            Style   = Screen.Style.ListViewStyle;

            Scrollbar        = new Scrollbar(_screen);
            Scrollbar.Parent = this;

            ActionButtons = new ObservableList <Button>();

            ActionButtons.ListCleared += delegate {
                mHoveredActionButton = null;
            };

            ActionButtons.ListChanged += delegate {
                if (mHoveredActionButton != null && !ActionButtons.Contains(mHoveredActionButton))
                {
                    mHoveredActionButton = null;
                }
            };

            UpdateContentSize();
        }