Visual Studio 2010 디자이너는 처리되지 않은 예외가 MultiValueConverter에서 발생했지만 프로그램을 빌드 할 수 있으며 잘 작동합니다 (다중 연결도 가능함).WPF MultiBinding VS 디자이너 예외
<ComboBox Name="cbbProfile" DisplayMemberPath="Name" Grid.Row="1" Margin="10,5" Grid.ColumnSpan="3" ItemsSource="{Binding ProfilesData.ProfilesItems}" SelectionChanged="cbbProfile_SelectionChanged" >
<ComboBox.IsEnabled>
<MultiBinding Converter="{StaticResource multiEnabledToEnabled}">
<Binding Path="ProfilesData.ProfilesItems.Count" Converter="{StaticResource itemsCountToEnabled}" />
<Binding Path="State" Converter="{StaticResource stateToControlsEnabled}" />
</MultiBinding>
</ComboBox.IsEnabled>
</ComboBox>
컨버터 :
public class MultiEnabledToEnabled : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
foreach (object val in values)
{
if (!(bool) val) // <-- EXCEPTION (line 176) HERE
return false;
}
return true;
}
public class ItemsCountToEnabled : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)value == 0 ? false : true;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class StateToControlsEnabled : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var val = (ProgramState)value;
switch (val)
{
...
default:
return true;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
VS 예외 텍스트 :
System.InvalidCastException 지정한 캐스트
XAML은 (내가 생성자 window.DataContext 설정) 유효하지 않습니다. at myassemblyname.MultiEnabledToEnabled.Convert (Object [] values, Type targetType, Object 매개 변수, CultureInfo 문화권) C : ... \ Converters.cs : Line 176 at System.Windows.Data.MultiBindingExpression.TransferValue() at System.Windows.Data.MultiBindingExpression에서 System.Windows.Data.MultiBindingExpression.AttachToContext (부울 lastChance) 에서 System.Windows.Data.MultiBindingExpression.UpdateTarget (부울 includeInnerBindings) 에서 System.Windows.Data.MultiBindingExpression.Transfer() .MS.Internal.Data.IDataBindEngineClient.AttachToContext (Boolean lastChance) MS.Internal.Data.DataBindEngine.Task.Run (부울 lastChance) at MS.Internal.Data.DataBindEngine.Run (Object arg) at System. Windows.Threading.Excep tionWrapper.InternalRealCall MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen에서 (위임 콜백, 객체 인수, INT32 numArgs) (오브젝트 소스, 위임 방법, 인수 객체, INT32 numArgs, 위임 catchHandler)