あなたは、コンバータを必要とする:
namespace Jahedsoft
{
[ValueConversion(typeof(object), typeof(string))]
public class StringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value == null ? null : value.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
今、あなたはこのようにそれを使用することができます:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:j="clr-namespace:Jahedsoft">
<j:StringConverter x:Key="StringConverter" />
</ResourceDictionary>
...
<Style TargetType="{x:Type MyControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type MyControl}">
<TextBlock Text="{TemplateBinding Property=VersionNumber, Converter={StaticResource StringConverter}}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
あなたがバインドしている 'VersionNumber'プロパティがダブルではない可能性があります。なぜあなたはあなたが期待しているバインディング動作を見ていないのか説明できますか? – yzorg