Быстрый обходной путь с помощью ValueConverter:
Создайте ValueConverter в своем коде:
// of course use your own namespace...
namespace MyNameSpace
{
public class IndexConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if(!(value is int)) // Add the breakpoint here!!
throw new Exception();
int newindex = ((int)value - 1;
return newindex;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException("This method should never be called");
}
}
}
Затем сделайте его известным в своем XAML:
//(declare a namespace in your window tag:)
xmlns:myNamespace="clr-namespace:MyNameSpace"
// add:
<Window.Resources>
<ResourceDictionary>
<myNamespace:IndexConverter x:Key="indexConverter" />
</ResourceDictionary>
</Window.Resources>
Тогдаизмените привязку:
<ComboBox SelectedIndex="{Binding SC.User1.UserID, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource indexConverter}}" ... />
Это должно сработать.По крайней мере, вы можете отладить его, вставив точку останова в IndexConverter.