WPF Codeplex 仪表板双向拨号
BidirectionalDial tempGauge = new Dial360();
if (chp.DialType.Equals("360"))
{
tempGauge = new Dial360();
}
else if (chp.DialType.Equals("180"))
{
tempGauge = new Dial180North();
}
else if (chp.DialType.Equals("90"))
{
tempGauge = new Dial90SouthEast();
}
tempGauge.FontSize = GaugeDialProperty.getGaugeFontSize(chp.DialType, chp.MaxVal);
GetGaugeFontSize
返回一个整数,但仅适用于 Dial360
。它不适用于 Dial180North
和 Dial90SouthEast
,它们使用默认字体大小。我该如何解决这个问题?
解决方案:
Grid dg = (Grid)tempGauge.Content;
foreach (UIElement ui in dg.Children)
{
Type elementType = ui.GetType();
if (elementType.FullName == "System.Windows.Controls.TextBlock")
{
TextBlock tb = (TextBlock)ui;
tb.FontSize = fontSize;
}
}
BidirectionalDial tempGauge = new Dial360();
if (chp.DialType.Equals("360"))
{
tempGauge = new Dial360();
}
else if (chp.DialType.Equals("180"))
{
tempGauge = new Dial180North();
}
else if (chp.DialType.Equals("90"))
{
tempGauge = new Dial90SouthEast();
}
tempGauge.FontSize = GaugeDialProperty.getGaugeFontSize(chp.DialType, chp.MaxVal);
GetGaugeFontSize
returns an integer but it is only applied to Dial360
. It is not applyed to Dial180North
and Dial90SouthEast
and they use default font size. How can I solve this issue?
Solution:
Grid dg = (Grid)tempGauge.Content;
foreach (UIElement ui in dg.Children)
{
Type elementType = ui.GetType();
if (elementType.FullName == "System.Windows.Controls.TextBlock")
{
TextBlock tb = (TextBlock)ui;
tb.FontSize = fontSize;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论