>>In Visual Studio 2010, I have a XAML screen with a textbox defined like this:
>>
>>
< TextBox Name="txtBalanceOutstanding"
>> Grid.Row="9" Grid.Column="1" Grid.ColumnSpan="1" Height="23"
>> HorizontalAlignment="Stretch" Margin="0,0,100,0"
>> IsReadOnly="True" FontWeight="Bold" Focusable="False" VerticalContentAlignment="Center" >
>>
>> < /TextBox >
>>
>>
>>
>>When I change it to this (adding in the MultiBinding):
>>
>>
<TextBox Name="txtBalanceOutstanding"
>> Grid.Row="9" Grid.Column="1" Grid.ColumnSpan="1" Height="23"
>> HorizontalAlignment="Stretch" Margin="0,0,100,0"
>> IsReadOnly="True" FontWeight="Bold" Focusable="False" VerticalContentAlignment="Center">
>> <MultiBinding Converter="{StaticResource OutstandingBalanceConverter}">
>> <Binding ElementName="txtDepositTotal" Path="Text"></Binding>
>> <Binding ElementName="txtDep_Amount" Path="Text"></Binding>
>> </MultiBinding>
>> </TextBox>
>>
>>
>>
>>The screen designer shows an unhandled exception error has occurred:
>>
>>Unable to cast object of type 'MS.Internal.NamedObject' to type 'System.String'.
>> at System.Linq.Enumerable.< CastIterator >d__b1`1.MoveNext()
>> at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
>> at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
>> at SamaanSystems.IBC.WPF.OutstandingBalanceConverter.Convert(Object[] values, Type targetType, Object parameter, CultureInfo culture) in D:\Development\VS2010\IBC\IBC WPF\Converters\OutstandingBalanceConverter.cs:line 13
>> at System.Windows.Data.MultiBindingExpression.TransferValue()
>> at System.Windows.Data.MultiBindingExpression.Transfer()
>> at System.Windows.Data.MultiBindingExpression.UpdateTarget(Boolean includeInnerBindings)
>> at System.Windows.Data.MultiBindingExpression.AttachToContext(Boolean lastChance)
>> at System.Windows.Data.MultiBindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
>> at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
>> at MS.Internal.Data.DataBindEngine.Run(Object arg)
>> at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
>> at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
>>
>>Any idea what I'm doing wrong?
>
>Can you post the OutstandingBalanceConverter code ?
Hi Viv,
I got it sorted out by ensuring the controls were named/referenced properly.