Exemplo n.º 1
0
        private void ChangeItemSelection(object item, bool isSelected)
        {
            var listBoxItem = _listControl.GetListBoxItemFromItem(item);

            if (listBoxItem != null && listBoxItem.Content != null)
            {
                ((DataGridRow)listBoxItem.Content).IsSelected = isSelected;
            }
        }
Exemplo n.º 2
0
        private void ChangeItemSelection(object item, bool isSelected)
        {
            var listBoxItem = _listControl.GetListBoxItemFromItem(item);

            if (listBoxItem != null && listBoxItem.Content != null)
            {
                ((DataGridRow)listBoxItem.Content).IsSelected = isSelected;
            }

            var row = (DataGridRow)listBoxItem?.Content;

            if (SelectionMode == SelectionMode.Multiple)
            {
                if (isSelected)
                {
                    SelectedRows.Add(item);
                }
                else
                {
                    SelectedRows.Remove(item);
                }
            }

            var columnIndex = 0;

            if (!isSelected && row != null)
            {
                foreach (var column in Columns)
                {
                    var cell = column.CreateCell(this, item);

                    //   var cellControl= GetContentPreseneterFromItem(column);
                    cell.Control.Tag         = cell;
                    cell.Control.DataContext = item;

                    // var cellControl = new ContentPresenter();
                    var cellControl = (ContentPresenter)row.Children[columnIndex];
                    cellControl.Content                    = cell;
                    cellControl.ContentTemplate            = this.CellTemplate;
                    cellControl.HorizontalContentAlignment = HorizontalAlignment.Stretch;
                    cellControl.VerticalContentAlignment   = VerticalAlignment.Stretch;
                    columnIndex++;
                }
            }

            SelectedValues = _listControl.SelectedItems.ToList();
        }