Комодо замечателен, и он работает на OS X; у них есть бесплатная версия, Редактирование Комодо.
ОБНОВЛЕНИЕ с 2015: я переключился на PHPStorm от Jetbrains, те же люди, которые создали IntelliJ IDEA и Resharper. Это лучше. Не просто лучше. Это определенно стоит денег.
I Я использую .NET 3.5 SP1, поэтому это очень просто:
<TextBox Text="{Binding Price, TargetNullValue=''}"/>
Что означает (спасибо Грегору за ваш комментарий):
<TextBox Text="{Binding Price, TargetNullValue={x:Static sys:String.Empty}}"/>
sys
- это импортированное пространство имен xml для System
в mscorlib
:
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Надеюсь, что это помогло.
This value converter should do the trick :
public class StringToNullableDecimalConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
CultureInfo culture)
{
decimal? d = (decimal?)value;
if (d.HasValue)
return d.Value.ToString(culture);
else
return String.Empty;
}
public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
{
string s = (string)value;
if (String.IsNullOrEmpty(s))
return null;
else
return (decimal?)decimal.Parse(s, culture);
}
}
Declare an instance of this converter in the ressources :
<Window.Resources>
<local:StringToNullableDecimalConverter x:Key="nullDecimalConv"/>
</Window.Resources>
And use it in your binding :
<TextBox Text="{Binding Price, Converter={StaticResource nullDecimalConv}}"/>
Note that TargetNullValue
is not appropriate here : it is used to define which value should be used when the source
of the binding is null. Here Price
is not the source, it's a property of the source...
Вы можете попробовать использовать ValueConverter (IValueConverter) http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx
Здесь, на затылке, что-то вроде:
public class DoubleConverter : IValueConverter
{
public object Convert(object value, Type targetType,
object parameter, CultureInfo culture)
{
return (double)value;
}
public object ConvertBack(object value, Type targetType,
object parameter, CultureInfo culture)
{
var doubleValue = Convert.ToDouble(value);
return (doubleValue == 0 ? null : doubleValue);
}
}
(Может потребоваться небольшая настройка хотя)