Button myButton = new Button(); myButton.Content = "A Button"; myButton.Background = Brushes.Red; 使用SolidColorBrush 結構建立 Color,並設定其 Color 屬性。 您可以使用 Colors 類別中的預先定義色彩,或使用靜態 Color 方法來建立 FromArgb。 下列範例示範如何使用預先定義的色彩...
DrawingBrush myBrush = new DrawingBrush(); GeometryDrawing backgroundSquare = new GeometryDrawing( Brushes.White, null, new RectangleGeometry(new Rect(0, 0, 100, 100))); GeometryGroup aGeometryGroup = new GeometryGroup(); aGeometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, 50,...
{varcurrentPoint = pointList[i];varnextPoint = pointList[i +1];// 先忽略最后一个点的错误计算varx = nextPoint.Point.X - currentPoint.Point.X;vary = nextPoint.Point.Y - currentPoint.Point.Y;// 拿着纸笔自己画一下吧,这个是简单的数学计算doubleangle = Math.Atan2(y, x) - Math.PI /2...
FormattedText formattedText = new FormattedText( testString, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Verdana"), 32, Brushes.Black); // Set a maximum width and height. If the text overflows these values, an ellipsis "..." appears. formattedText.MaxTextWidth...
Brushes enable you to paint user interface (UI) objects with anything from simple, solid colors to complex sets of patterns and images.Painting with a BrushA Brush "paints" an area with its output. Different brushes have different types of output. Some brushes paint an area with a solid ...
wp.Background = new SolidColorBrush(Colors.White);//遍历增加RectanglesRectangle r;for(inti =0; i <=10; i++) { r = new Rectangle(); r.Fill = new SolidColorBrush(Colors.LightGreen); r.Margin = new Thickness(10,10,10,10);
publicpartialclassMainWindow:Window{publicMainWindow(){InitializeComponent();}privatevoidMainWindow_OnStylusDown(object sender,StylusDownEventArgs e){varpolyline=newPolyline(){Stroke=Brushes.Black,StrokeThickness=5};InkCanvas.Children.Add(polyline);_pointCache[e.StylusDevice.Id]=polyline;foreach(varstylusPoi...
Background = Brushes.LightGray; // 设置悬停时的背景色 }; row.MouseLeave += (s, ev) => { if (rowIndexBackgroundColors.ContainsKey(row.GetIndex())) { row.Background = rowIndexBackgroundColors[row.GetIndex()]; } }; } }; 如果你想在运行时根据某些条件更改特定行的背景色,可以使用row...
selectedDA.StylusTipTransform = innerTransform; drawingContext.DrawGeometry(Brushes.White, null, GetGeometry(selectedDA)); } // ... } 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21.
Type t = typeof(System.Windows.Media.Brushes); PropertyInfo[] colors = t.GetProperties();foreach (PropertyInfo pColor in colors){StackPanel stkPnl = new StackPanel();stkPnl.Width = listBox1.Width; stkPnl.Orientation = Orientation.Horizontal; TextBlock txtColName = new TextBlock();txtCol...