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;
}
}