-1
我想用類,而不是XAML風格如何使用
此代碼工作的WinForms應用創建圓形按鈕類,我怎樣才能將其轉換爲WPF代碼創建WPF圓角按鈕?
public class RoundButton : Button
{
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
GraphicsPath grPath = new GraphicsPath();
grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
this.Region = new System.Drawing.Region(grPath);
base.OnPaint(e);
}
}
難道那種打敗XAML的整個目的?如果你使用的是WPF,你應該做[類似於這個](https://stackoverflow.com/questions/2601604/wpf-user-control-round-corners-programmatically)。 – Sach