and to avoid the mess of knowing what to call (original combo or new instance):
ComboBox _cbAddTableDlgTypeRebindWorkAround =
null;
///
<summary>
/// If you have blank items and then rebind with data, the dropdown box is shown
/// wrong :-(.
///
/// You have to use a hack, recreate the combo dynamically. Use this property
/// always instead of calling cbEdTableOrigin
///
</summary>
public
ComboBox CbAddTableDlgTypeRebindWorkAround
Thanks for your reporting. It's a known issue that we're now investigating.
I am fighting this bug too.
Allen- Any word on when we might see an update? I'm demoing my app tomorrow with a release early next week. The ComboBox and DataGrid bugs are leaving me wondering if I should book a one-way plane ticket to some foreign land to avoid being drawn-and-quartered
by my users. One thing is for certain, the CB and DG controls are most definitely not ready for prime-time. I'm really questioning my decision to go with Silverlight for this project... :(
Turns out that the NameProperty has to be unique when adding items to a Container like a grid for example. The child added is a user control here in my case.
private
static
int componentID = 0;
private
Grid tableGrid;
FrameworkElement
element; //this is a user control.
element.SetValue(
Canvas.NameProperty, GetComponentID().ToString());
private
static
int GetComponentID()
{
return componentID++;
}
//This will not give the 'Value does not fall within the expected range' exception. [:)]
Was having the same/similar error message (how I found this post) - turned out it was because of the RowStyle="" setting in the sample below. Have
a look to see if any empty settings in your XAML
Can you please let your MSFT colleagues know that an error message like this:
Sys.InvalidOperationException: ManagedRuntimeError error #4004 in control 'Xaml1': System.ArgumentException: Value does not fall within the expected range as MS.Internal.XcpImports.CheckHResult(UInt32 hr)
is completely unacceptable? It does not tell what control is involved (I don't have a control 'Xaml1'), it does not tell what the
Value is, nor what the expected range is. So this error message is equivalent to
Something is wrong but I won't take the trouble telling you what it is.
I have a UserControl in a RowDetailsTemplate. Seems like a sound approach:
<data:DataGrid.RowDetailsTemplate>
<DataTemplate>
<uc:ListDetails
x:Name="DetailsPanel"/>
</DataTemplate>
</data:DataGrid.RowDetailsTemplate>
The first time the ListDetails are displayed everything is fine. But upon selecting another row I got the (almost) useless error message. Replacing the ListDetails by a Grid (container) and creating the ListDetails as a child dynamically in its Loaded event
handler (similar to deriven's approach) avoids the error.
(So the error message did have some use: it took me here.)
I'm seeing the same issue in Silverlight 4 same error. Any resolution yet. What happen is when i assign null to ViewModel its Models still stay intact. and i see debugger still stepping through model code
{System.ArgumentException: Value does not fall within the expected range.
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
at System.Windows.Data.BindingExpression.SendDataToTarget()
at System.Windows.Data.BindingExpression.SourceAcquired()
at System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(Object sender, DataContextChangedEventArgs e)
at System.Windows.Data.BindingExpression.DataContextChanged(Object sender, DataContextChangedEventArgs e)
at System.Windows.FrameworkElement.OnDataContextChanged(DataContextChangedEventArgs e)
at System.Windows.FrameworkElement.OnTreeParentUpdated(DependencyObject newParent, Boolean bIsNewParentAlive)
at System.Windows.DependencyObject.UpdateTreeParent(IManagedPeer oldParent, IManagedPeer newParent, Boolean bIsNewParentAlive, Boolean keepReferenceToParent)
at MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(IntPtr oldParentElement, IntPtr parentElement, IntPtr childElement, Byte bIsParentAlive, Byte bKeepReferenceToParent, Byte bCanCreateParent)}
Brauliod
Contributor
2448 Points
744 Posts
Re: Re: Re: System.ArgumentException: Value does not fall within the expected range at Ms.Interna...
Nov 05, 2008 09:28 AM | LINK
Yes I have to destroy and create a new one (with the same ID):
I use something like:public ComboBox BindItemsSourceAndForceDropdownBoxSizeRecalc(Grid parent, ComboBox cbOrigin, System.Collections.IEnumerable itemsSource, SelectionChangedEventHandler selectionChangedEventHanlder){
ComboBox newComboBox = new ComboBox();newComboBox.Name = cbOrigin.Name;
newComboBox.ItemsSource = itemsSource;
newComboBox.HorizontalAlignment = cbOrigin.HorizontalAlignment;
newComboBox.SetValue(Grid.RowProperty, cbOrigin.GetValue(Grid.RowProperty));newComboBox.SetValue(Grid.ColumnProperty, cbOrigin.GetValue(Grid.ColumnProperty));newComboBox.SelectionChanged += selectionChangedEventHanlder;
newComboBox.DisplayMemberPath = cbOrigin.DisplayMemberPath;
newComboBox.Width = cbOrigin.Width;
newComboBox.Height = cbOrigin.Height;
parent.Children.Remove(cbOrigin);
parent.Children.Add(newComboBox);
newComboBox.SelectedIndex = 0;
return newComboBox;}
and to avoid the mess of knowing what to call (original combo or new instance):
ComboBox _cbAddTableDlgTypeRebindWorkAround = null; /// <summary> /// If you have blank items and then rebind with data, the dropdown box is shown /// wrong :-(. /// /// You have to use a hack, recreate the combo dynamically. Use this property /// always instead of calling cbEdTableOrigin /// </summary> public ComboBox CbAddTableDlgTypeRebindWorkAround{
get{
return (_cbAddTableDlgTypeRebindWorkAround == null) ? cbAddTableDlgType : _cbAddTableDlgTypeRebindWorkAround;}
}
Book: Mastering LOB Development for Silverlight 5: A Case Study in Action
CoderX
Member
178 Points
96 Posts
Re: More detail about the Exception...
Nov 05, 2008 11:25 PM | LINK
I am fighting this bug too.
Allen- Any word on when we might see an update? I'm demoing my app tomorrow with a release early next week. The ComboBox and DataGrid bugs are leaving me wondering if I should book a one-way plane ticket to some foreign land to avoid being drawn-and-quartered by my users. One thing is for certain, the CB and DG controls are most definitely not ready for prime-time. I'm really questioning my decision to go with Silverlight for this project... :(
orangechicken
Member
19 Points
20 Posts
Re: Re: More detail about the Exception...
Jan 12, 2009 02:24 PM | LINK
Any update on this? It's still a bug in RTW as far as I can tell. Getting it when setting the Child property on a Popup.
Sudhir Murthy
Member
4 Points
2 Posts
Re: Re: Re: More detail about the Exception...
Jan 15, 2009 09:54 AM | LINK
I found an interesting fix for this issue.
Turns out that the NameProperty has to be unique when adding items to a Container like a grid for example. The child added is a user control here in my case.
private static int componentID = 0; private Grid tableGrid;FrameworkElement
element; //this is a user control.element.SetValue(
Canvas.NameProperty, GetComponentID().ToString()); private static int GetComponentID(){
return componentID++;}
//This will not give the 'Value does not fall within the expected range' exception. [:)]
tableGrid.Children.Add(element);
Cheers!
Sudhir
turneye
Member
2 Points
1 Post
Re: Re: Re: More detail about the Exception...
Feb 26, 2009 08:58 AM | LINK
Was having the same/similar error message (how I found this post) - turned out it was because of the RowStyle="" setting in the sample below. Have a look to see if any empty settings in your XAML
<data:DataGrid x:Name="woHistory" AutoGenerateColumns="False" RowStyle="" AlternatingRowBackground="Black" Margin="2">
Not sure how that got there, might have been something I did in Expression Studio....
.turneye.
ninjapixel
Member
2 Points
1 Post
Re: More detail about the Exception...
Apr 22, 2009 11:04 AM | LINK
Any updates on this issue?
Thanks
marcschluper
Member
56 Points
48 Posts
Re: More detail about the Exception...
May 28, 2009 04:35 PM | LINK
Dear Allen Chen,
Can you please let your MSFT colleagues know that an error message like this:
Sys.InvalidOperationException: ManagedRuntimeError error #4004 in control 'Xaml1': System.ArgumentException: Value does not fall within the expected range as MS.Internal.XcpImports.CheckHResult(UInt32 hr)
is completely unacceptable? It does not tell what control is involved (I don't have a control 'Xaml1'), it does not tell what the Value is, nor what the expected range is. So this error message is equivalent to
Something is wrong but I won't take the trouble telling you what it is.
Thank you.
Complaint
marcschluper
Member
56 Points
48 Posts
Re: Re: More detail about the Exception...
May 28, 2009 05:53 PM | LINK
The first time the ListDetails are displayed everything is fine. But upon selecting another row I got the (almost) useless error message. Replacing the ListDetails by a Grid (container) and creating the ListDetails as a child dynamically in its Loaded event handler (similar to deriven's approach) avoids the error.
(So the error message did have some use: it took me here.)
ravindranathw
Member
32 Points
31 Posts
Re: More detail about the Exception...
Nov 28, 2011 05:52 PM | LINK
I'm seeing the same issue in Silverlight 4 same error. Any resolution yet. What happen is when i assign null to ViewModel its Models still stay intact. and i see debugger still stepping through model code
{System.ArgumentException: Value does not fall within the expected range.
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase doh, DependencyProperty property, Object obj)
at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
at System.Windows.Data.BindingExpression.SendDataToTarget()
at System.Windows.Data.BindingExpression.SourceAcquired()
at System.Windows.Data.BindingExpression.System.Windows.IDataContextChangedListener.OnDataContextChanged(Object sender, DataContextChangedEventArgs e)
at System.Windows.Data.BindingExpression.DataContextChanged(Object sender, DataContextChangedEventArgs e)
at System.Windows.FrameworkElement.OnDataContextChanged(DataContextChangedEventArgs e)
at System.Windows.FrameworkElement.OnTreeParentUpdated(DependencyObject newParent, Boolean bIsNewParentAlive)
at System.Windows.DependencyObject.UpdateTreeParent(IManagedPeer oldParent, IManagedPeer newParent, Boolean bIsNewParentAlive, Boolean keepReferenceToParent)
at MS.Internal.FrameworkCallbacks.ManagedPeerTreeUpdate(IntPtr oldParentElement, IntPtr parentElement, IntPtr childElement, Byte bIsParentAlive, Byte bKeepReferenceToParent, Byte bCanCreateParent)}