Exemplo n.º 1
0
		internal DataGridRow(DataGrid dataGrid, object item)
		{
			Item = item;
			DataGrid = dataGrid;
			
			var x = 0;
			var hasStar = false;
			foreach (var c in dataGrid.Columns)
			{
				var cell = c.GenerateElement(item);

                var content = new ContentPresenter();
                content.Content = cell.Control;
                content.Margin = new Thickness(10, 0, 0, 5);
                content.Tag = cell; 

				SetColumn(content, x++);
				Children.Add(content);
			
				var def = c.CreateGridColumnDefinition();
				hasStar = hasStar || def.Width.IsStar;
				ColumnDefinitions.Add(def);
			}

			if (!hasStar)
				ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

			// second row used for details view
			RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
			RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
		}
Exemplo n.º 2
0
        internal DataGridRow(DataGrid dataGrid, object item)
        {
            Item = item;
            DataGrid = dataGrid;

            var hasStar = CreateCells(item);
            CreateColumnAndRowDefinitions(hasStar);

            Loaded += OnLoaded;
        }
        /// <summary>Generates the cell for the given item.</summary>
        /// <param name="dataGrid">The data grid.</param>
        /// <param name="dataItem">The item to generate the cell for.</param>
        /// <returns>The <see cref="DataGridCellBase" />.</returns>
        public override DataGridCellBase CreateCell(DataGrid dataGrid, object dataItem)
        {
            var control = new ContentControl();
            control.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            control.VerticalContentAlignment = VerticalAlignment.Stretch;
            control.Content = dataItem;
            control.ContentTemplate = CellTemplate;

            if (OnlyVisibleOnSelection)
                control.Visibility = IsSelected ? Visibility.Visible : Visibility.Collapsed;

            return new DataGridTemplatedCell(control, OnlyVisibleOnSelection);
        }
Exemplo n.º 4
0
        internal DataGridRow(DataGrid dataGrid, object item)
        {
            Item = item;
            DataGrid = dataGrid;

            var x = 0;
            var hasStar = false;
            foreach (var c in dataGrid.Columns)
            {
                var cell = c.GenerateElement(item);

                var content = new ContentPresenter();
                content.Content = cell.Control;
                //content.ContentTemplate = dataGrid.CellTemplate;
                content.Margin = new Thickness(10, 0, 0, 5); // TODO: Use template and remove margin
                content.Tag = cell;

                SetColumn(content, x++);
                Children.Add(content);

                var def = c.CreateGridColumnDefinition();
                hasStar = hasStar || def.Width.IsStar;

                ColumnDefinitions.Add(def);
            }

            if (!hasStar)
                ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

            // second row used for details view
            RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
            RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });

            Loaded += delegate
            {
                if (DataGrid.SelectionMode == SelectionMode.Single)
                {
                    if (DataGrid.SelectedItem != null)
                        IsSelected = DataGrid.SelectedItem.Equals(item);
                }
                else
                {
                    if (DataGrid.SelectedItems != null)
                        IsSelected = DataGrid.SelectedItems.Contains(item);
                }
            };
        }
Exemplo n.º 5
0
        /// <summary>Generates the cell for the given item. </summary>
        /// <param name="dataGrid"></param>
        /// <param name="dataItem">The item to generate the cell for. </param>
        /// <returns>The <see cref="DataGridCellBase"/>. </returns>
        public override DataGridCellBase CreateCell(DataGrid dataGrid, object dataItem)
        {
            var block = new TextBlock();
            block.VerticalAlignment = VerticalAlignment.Center;

            if (FontSize <= 0)
                FontSize = dataGrid.FontSize;

            CreateBinding(StyleProperty, "Style", block, TextBlock.StyleProperty);
            CreateBinding(FontStyleProperty, "FontStyle", block, TextBlock.FontStyleProperty);
            CreateBinding(FontSizeProperty, "FontSize", block, TextBlock.FontSizeProperty);
            CreateBinding(ForegroundProperty, "Foreground", block, TextBlock.ForegroundProperty);

            if (Binding != null)
                block.SetBinding(TextBlock.TextProperty, Binding);

            return new DefaultDataGridCell(block);
        }
Exemplo n.º 6
0
 /// <summary>Generates the cell for the given item. </summary>
 /// <param name="dataGrid">The data grid.</param>
 /// <param name="dataItem">The item to generate the cell for. </param>
 /// <returns>The <see cref="DataGridCellBase"/>. </returns>
 public abstract DataGridCellBase CreateCell(DataGrid dataGrid, object dataItem);
Exemplo n.º 7
0
 public override DataGridCellBase CreateCell(MyToolkit.Controls.DataGrid dataGrid, object dataItem)
 {
     throw new NotImplementedException();
 }