圖形在WPF對象比的Winforms不同的,因爲WPF使用矢量圖形。在WPF中,你將使用一個DrawingVisual,DrawingContext,FormattedText和BitmapImage,在圖形中的WinForms對象的DrawingContext等同。這是展示我的意思的一個快速示例。
public MainWindow()
{
InitializeComponent();
Grid myGrid = new Grid();
BitmapImage bmp = new BitmapImage(new Uri(@"C:\temp\test.jpg")); //Use the path to your Image
DrawingVisual dv = new DrawingVisual();
DrawingContext dc = dv.RenderOpen();
dc.DrawImage(bmp, new Rect(100, 100, 300, 300));
dc.DrawText(new FormattedText("Hello World",
CultureInfo.GetCultureInfo("en-us"),
FlowDirection.LeftToRight,
new Typeface("Arial"),
30, System.Windows.Media.Brushes.Black),
new System.Windows.Point(100, 120));
dc.Close();
myGrid.Background = new VisualBrush(dv);
this.Content = myGrid;
}
Winforms中運行時,它不適合你的工作,例如..?檢查該工作示例 - http://stackoverflow.com/questions/6311545/c-sharp-write-text-on-bitmap – MethodMan