我试图将标签填充到水平滑块上,并且通过将Text传递给FormattedText构造函数,使用从TickBar派生的类成功地做到了这一点。但是现在,当我将相同的代码粘贴到使用.net Framework 4.6.2版的Visual Studio中时,它说:
FormattedText.FormttedText已过时。使用PixelsPerDip替代。
我在.NET Framework 4.6.2中提到过FormattedText()已过时,我该如何修复
但是在当前情况下我该如何使用它。请帮忙。
FormattedText formattedText = new FormattedText(text, CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, new Typeface("Verdana"), 16, Brushes.Black);
dc.DrawText(formattedText, new Point((tickFrequencySize * i), 30)); //dc is Drawing Context.
Run Code Online (Sandbox Code Playgroud)
这是完整的课程
public class CustomTickBar : TickBar
{
public static string FontTextList { get; set; }
protected override void OnRender(DrawingContext dc)
{
//string str = "Small, Medium, Large, Extra\n Large";
if (!string.IsNullOrEmpty(FontTextList))
{
string[] ar = FontTextList.Split(',');
Size size = new Size(base.ActualWidth, base.ActualHeight);
int tickCount = (int)((this.Maximum - …Run Code Online (Sandbox Code Playgroud)