你应该在你的 Xaml 代码中尝试
<TextBlock>
<Run Text="Full date/time pattern (short time): "/>
<Run Text="{Binding DateTime, StringFormat=f, ElementName=userControl}"/>
</TextBlock>
<TextBlock>
<Run Text="Full date/time pattern (long time): "/>
<Run Text="{Binding DateTime, StringFormat=F, ElementName=userControl}"/>
</TextBlock>
<TextBlock>
<Run Text="Short date/time pattern (short time): "/>
<Run Text="{Binding DateTime, StringFormat=g, ElementName=userControl}"/>
</TextBlock>
<TextBlock>
<Run Text="Short date/time pattern (long time): "/>
<Run Text="{Binding DateTime, StringFormat=G, ElementName=userControl}"/>
</TextBlock>
或者
<TextBlock>
<Run Text="In Currency with zero decimal point: "/>
<Run Text="{Binding Number, StringFormat=\{0:c0\}, ElementName=userControl}"/>
</TextBlock>
<TextBlock>
<Run Text="In Currency with two decimal point: "/>
<Run Text="{Binding Number, StringFormat=\{0:c2\}, ElementName=userControl}"/>
</TextBlock>
或者
<TextBlock>
<Run Text="Normal Number: "/>
<Run Text="{Binding Number, ElementName=userControl}"/>
</TextBlock>
<TextBlock>
<Run Text="Above number with 2 decimal point: "/>
<Run Text="{Binding Number, StringFormat=\{0:n2\}, ElementName=userControl}"/>
</TextBlock>
<TextBlock>
<Run Text="Above number with 4 decimal point: "/>
<Run Text="{Binding Number, StringFormat=\{0:n4\}, ElementName=userControl}"/>
</TextBlock>
<TextBlock>
<Run Text="Above number with 10 Zero place holder: "/>
<Run Text="{Binding Number, StringFormat=\{0:0000000000\}, ElementName=userControl}"/>
</TextBlock>
或者
<TextBlock>
<Run Text="Normal string: "/>
<Run Text="{Binding Text, ElementName=userControl}"/>
</TextBlock>
<TextBlock>
<Run Text="String with atleast 15 characters length: "/>
<Run Text="{Binding Text, StringFormat=\{0\,15\}, ElementName=userControl}"/>
</TextBlock>
<TextBlock>
<Run Text="String with atleast 25 characters length: "/>
<Run Text="{Binding Text, StringFormat=\{0\,25\}, ElementName=userControl}"/>
</TextBlock>
<TextBlock>
<Run Text="Text with quote: "/>
<Run Text="{Binding Text, StringFormat='The string "\{0\}" inside a quot',
ElementName=userControl}"/>
</TextBlock>