Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unable to cast object of type 'MS.Internal.NamedObject'
Message
From
10/03/2013 03:46:50
 
 
To
09/03/2013 13:29:09
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01567887
Message ID:
01567936
Views:
21
>>>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.

Thought that must be the problem - but I've never seen that type of error before (in a WPF context).
Usually the Output window will give a good indication of any binding problems - or you can configure a TraceListener as shown here:
http://www.codeproject.com/Articles/244107/Debugging-WPF-data-bindings
Previous
Reply
Map
View

Click here to load this message in the networking platform