How to use CollectionContainer as ItemsSource?
-
Thursday, March 24, 2011 9:30 AM
Hello,
I have a small code sample that works fine
<ContextMenu ItemsSource="{BindingPath=AvailableViews}">
AvailableViews is an ObservableCollection.
If I like to extend it in the following way it dosn't work, the contextMenue appears empty:
<ContextMenu> <ContextMenu.ItemsSource> <CompositeCollection> <CollectionContainer Collection="{Binding Path=AvailableViews}" /> </CompositeCollection> </ContextMenu.ItemsSource> </ContextMenu>
My question is: Why doesn't work the second code snippet?
Roy
All Replies
-
Thursday, March 24, 2011 10:01 AM
I see in
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b15cbd9d-95aa-47c6-8068-7ae9f7dca88a
it is a bug.
Roy
- Marked As Answer by Bob_BaoMVP, Moderator Thursday, March 31, 2011 7:56 PM
-
Friday, March 25, 2011 5:11 AMModerator
Hi RMxxx,
Thank you for this feedback, I will continue to consult internal for this issue. On the other hand, we have a workaround:
<Window.Resources> <CollectionViewSource x:Key="source" Source="{Binding AvailableViews}"/> </Window.Resources> <Grid Background="Red"> <Grid.ContextMenu> <!--<ContextMenu ItemsSource="{Binding Path=AvailableViews}"/>--> <ContextMenu> <ContextMenu.ItemsSource> <CompositeCollection> <CollectionContainer Collection="{Binding Source={StaticResource source}}" /> </CompositeCollection> </ContextMenu.ItemsSource> </ContextMenu> </Grid.ContextMenu> </Grid>
Please check it out.
Sincerely,
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Marked As Answer by Bob_BaoMVP, Moderator Thursday, March 31, 2011 7:56 PM

