我有这个 XAML:
<Label Text="{Binding val1, StringFormat={StaticResource CommaInteger}}"/>
<Label Text="{Binding val2, StringFormat={StaticResource CommaInteger}}"/>
我想将其简化为:
<local:commaIntLbl Text="{Binding val1}"/>
<local:commaIntLbl Text="{Binding val2}"/>
我应该如何编码我的 commaIntLbl 类来实现这一点?
public class commaIntLbl : Label
{
public commaIntLbl() : base()
{
SetDynamicResource(StyleProperty, "IntegerLabel");
// How to refer its Text's string-format to the StaticResource CommaInteger?
}
}