Charles Bates
Top achievements
Rank 1
Charles Bates
asked on 06 Oct 2010, 05:11 PM
Hello,
VS2010, SL 4, RadControls 2010.1.422.1030
We are trying to move a RadTabItem from one RadTabControl to another.
VS2010, SL 4, RadControls 2010.1.422.1030
We are trying to move a RadTabItem from one RadTabControl to another.
foreach
(RadTabItem ti
in
_leftTabCntrl.Items)
{
if
(ti.IsSelected)
{
removeLeftMapItem(ti);
addRightMapItem(ti);
ti.IsSelected =
true
;
break
;
}
}
private
void
removeLeftMapItem(RadTabItem item)
{
_leftTabCntrl.SelectionChanged -= TabCntrl_SelectionChanged;
_leftTabCntrl.Items.Remove(item);
--_countLeftMaps;
_leftTabCntrl.SelectionChanged += TabCntrl_SelectionChanged;
}
When Remove() executes, get this exception:
at MS.Internal.XcpImports.Collection_RemoveAt[T](PresentationFrameworkCollection`1 collection, UInt32 index)
at System.Windows.PresentationFrameworkCollection`1.RemoveAtImpl(Int32 index)
at System.Windows.Controls.ItemsControl.RemoveContainerForPosition(GeneratorPosition position)
at System.Windows.Controls.ItemsControl.OnItemsChangedHandler(Object sender, ItemsChangedEventArgs args)
at System.Windows.Controls.Primitives.ItemsChangedEventHandler.Invoke(Object sender, ItemsChangedEventArgs e)
at System.Windows.Controls.ItemContainerGenerator.RemoveItem(Object item, Int32 itemIndex, DependencyObject container, Int32 containerCount, GeneratorPosition position, ItemBlock block, Int32 offsetFromBlockStart, Boolean raiseReplaceInsteadOfRemove)
at System.Windows.Controls.ItemContainerGenerator.OnItemRemoved(Object item, Int32 itemIndex, Boolean raiseReplaceInsteadOfRemove)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.ICollectionChangedListener.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Windows.Controls.WeakCollectionChangedListener.SourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.ItemCollection.NotifyCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Windows.Controls.ItemCollection.RemoveAtImpl(Int32 index)
at System.Windows.Controls.ItemCollection.RemoveImpl(Object value)
at System.Windows.Controls.ItemCollection.RemoveInternal(Object value)
at System.Windows.PresentationFrameworkCollection`1.Remove(T value)
at MsiMapperClient.V_Meeting.removeLeftMapItem(RadTabItem item)
What are we doing wrong?
Thanks for any advice...
5 Answers, 1 is accepted
0
Hello Charles Bates,
I've tried to reproduce your problem, but I wasn't able to, so could you please examine the attached project and see if you still have that issue ?
Sincerely yours,Zarko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Charles Bates
Top achievements
Rank 1
answered on 08 Oct 2010, 12:55 PM
Thanks for the reply.
Here is another piece in the puzzle...
We are trying to add Context Menus to the objects on our main Canvas.
When the object containing the Canvas is loaded, we do this:
By commenting the one line ("contextMenu.SetMenu(this, contextMenu)"), the problem with removing the RadTabItem from the collection goes away -- our application works as it did before trying to add the context menu.
Here is another piece in the puzzle...
We are trying to add Context Menus to the objects on our main Canvas.
When the object containing the Canvas is loaded, we do this:
CommandManager.SetCommandBindings(
this
, Model.GetCommandBindings());
var contextMenu =
new
ContextMenu();
var menuItem =
new
RadMenuItem();
var binding =
new
Binding(
"SomeCommand.Text"
);
BindingOperations.SetBinding(menuItem, HeaderedItemsControl.HeaderProperty, binding);
binding =
new
Binding(
"SomeCommand"
);
BindingOperations.SetBinding(menuItem, RadMenuItem.CommandProperty, binding);
contextMenu.Items.Add(menuItem);
menuItem =
new
RadMenuItem();
binding =
new
Binding(
"OtherCommand.Text"
);
BindingOperations.SetBinding(menuItem, HeaderedItemsControl.HeaderProperty, binding);
binding =
new
Binding(
"OtherCommand"
);
BindingOperations.SetBinding(menuItem, RadMenuItem.CommandProperty, binding);
contextMenu.Items.Add(menuItem);
//contextMenu.SetMenu(this, contextMenu);
0
Hello Charles Bates,
Unfortunately, we still couldn't reproduce the issue. Can you please try modifying the sample project that Zarko sent to reproduce the issue so that we can further investigate it?
Thank you in advance.
All the best,
Tina Stancheva
the Telerik team
Unfortunately, we still couldn't reproduce the issue. Can you please try modifying the sample project that Zarko sent to reproduce the issue so that we can further investigate it?
Thank you in advance.
All the best,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Kais
Top achievements
Rank 1
answered on 01 Mar 2011, 10:46 PM
Im having a similar issue.
I set a RadContextMenu on a RadTabItem using the xaml Im having a similar issue. I set a RadContextMenu on a RadTabItem using the xaml
telerik:RadContextMenu.ContextMenu="{StaticResource TabItemContextMenu}"
This is set in a Style targeted RadTabItem.
Then my RadTabControl is bound to a ViewModel collectoin ObservableCollection<TabItemViewModel> so the RadTabItems are generated internally. Finally when a tab item is closed by removing the ViewModel from the observablecollection I occasionally get an exception.
The exception (as I have source license for Telerik) is genrated in RadContextMenu.ClearReferences(), the line
this.elementWithContextMenu.Unloaded -= new RoutedEventHandler(this.OnElementWithContextMenuUnloaded);
On some occasions elementWithContextMenu is null. This method is called OnContextMenuChanged.
I am not sure what's happening here but sometimes the RadTabItem that the context menu is associated with internally gets nulled before the context menu is cleared. Strange?
I set a RadContextMenu on a RadTabItem using the xaml Im having a similar issue. I set a RadContextMenu on a RadTabItem using the xaml
telerik:RadContextMenu.ContextMenu="{StaticResource TabItemContextMenu}"
This is set in a Style targeted RadTabItem.
Then my RadTabControl is bound to a ViewModel collectoin ObservableCollection<TabItemViewModel> so the RadTabItems are generated internally. Finally when a tab item is closed by removing the ViewModel from the observablecollection I occasionally get an exception.
The exception (as I have source license for Telerik) is genrated in RadContextMenu.ClearReferences(), the line
this.elementWithContextMenu.Unloaded -= new RoutedEventHandler(this.OnElementWithContextMenuUnloaded);
On some occasions elementWithContextMenu is null. This method is called OnContextMenuChanged.
I am not sure what's happening here but sometimes the RadTabItem that the context menu is associated with internally gets nulled before the context menu is cleared. Strange?
0
Hello Kais,
Thank you for the detailed information. However, we still cannot reproduce the issue on our side and therefore we cannot be sure in which cases it comes up and what might be causing it. This is why I wanted to ask you for your assistance. I prepared a sample project that we used for testing. If you can have a look at it and let us know if it works for you or if illustrates your scenario correctly, that will greatly help us.
Thank you in advance for your cooperation.
Greetings,
Tina Stancheva
the Telerik team
Thank you for the detailed information. However, we still cannot reproduce the issue on our side and therefore we cannot be sure in which cases it comes up and what might be causing it. This is why I wanted to ask you for your assistance. I prepared a sample project that we used for testing. If you can have a look at it and let us know if it works for you or if illustrates your scenario correctly, that will greatly help us.
Thank you in advance for your cooperation.
Greetings,
Tina Stancheva
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!