コード例 #1
0
        private void PieceBindings(ListPieceWPF thisGraphics, ListViewPieceCP thisPiece)
        {
            thisGraphics.Width      = ItemWidth;
            thisGraphics.Height     = ItemHeight; // lets set to 20.
            thisGraphics.Visibility = Visibility.Visible;
            var thisBind = GetCommandBinding(nameof(ListViewPicker.ItemSelectedCommand));

            thisGraphics.SetBinding(GraphicsCommand.CommandProperty, thisBind);
            thisGraphics.CommandParameter = thisPiece; // must be piece, not simply the color.  something else will figure out the color.
            thisGraphics.Margin           = new Thickness(5, 0, 5, 5);
            thisGraphics.DataContext      = thisPiece;
            thisGraphics.SetBinding(ListPieceWPF.IsSelectedProperty, new Binding(nameof(BaseGraphicsCP.IsSelected))); // i think
            thisGraphics.SetBinding(IsEnabledProperty, new Binding(nameof(BaseGraphicsCP.IsEnabled)));
            thisGraphics.SetBinding(ListPieceWPF.TextProperty, new Binding(nameof(ListViewPieceCP.DisplayText)));
            thisGraphics.SetBinding(ListPieceWPF.IndexProperty, new Binding(nameof(ListViewPieceCP.Index)));
            thisGraphics.SendPiece(thisPiece);
        }
コード例 #2
0
        private void PopulateList()
        {
            if (TotalColumns == 0)
            {
                _thisStack !.Children.Clear();
            }
            else
            {
                _thisGrid !.Children.Clear();
            }
            int row    = 0;
            int column = 0;

            foreach (var thisPiece in _textList !)
            {
                ListPieceWPF thisGraphics = new ListPieceWPF();
                PieceBindings(thisGraphics, thisPiece);
                if (TotalColumns == 0)
                {
                    _thisStack !.Children.Add(thisGraphics);
                }
                else
                {
                    if (row + 1 > _thisGrid !.RowDefinitions.Count)
                    {
                        AddAutoRows(_thisGrid, 1); //add one as needed.
                    }
                    AddControlToGrid(_thisGrid !, thisGraphics, row, column);
                    column++;
                    if (column + 1 > TotalColumns)
                    {
                        column = 0;
                        row++;
                    }
                }
            }
        }