Click here to Skip to main content
12,826,151 members (27,431 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# WPF C#4.0 MVVM TabControl , +
Hello Every Body

I'm using wpf and mvvm pattern, in my program when you select a row in datagrid if ID equal zero Save Button Enabled and you can save the record;

so if I put datagrid in one TabItem and the Button To Othere TabItem(both of TabItems are blonged to one TabControl) ICommand CanExecute Method Not Working.

I used MS MVVM Light Toolkit ;

Excusme To bad English

Thank you
Posted 3-Nov-12 8:37am
Jason Gleim 3-Nov-12 13:57pm
Without some code it is hard to figure out what is going on. However, if I were to guess, you will find that the data grid and the button are now in two different data contexts. Use a tool like Snoop, XAML Spy, or WPF Spy to look at the tab items when your app is running and you will likely see they are not in the same data context. You will probably have to explicitly set the binding to your view model either in code or in xaml with DataContext="{Binding yourViewModel}"
ompcj4u 4-Nov-12 14:44pm
Hear I put My Some Code and My Project
Can you See them and tell me more about my Problem?
Thank you

My Project's Link :

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hi Jason
Excusme? What is Snoop? or XAML Spy or WPF Spy?

<usercontrol x:class="MVVMTestApplication.Views.CustomerView" xmlns:x="#unknown">
             mc:Ignorable="d" FontFamily="Tahoma" 
             d:DesignHeight="431" d:DesignWidth="483" FocusManager.FocusedElement="{Binding txtname}" xmlns:my="clr-namespace:Navigation;assembly=Navigation">

I Select Different Rows in Datagrid By "NewxItemCommand" and "BackItemCommand"
if AddNewCommand And InsertCommand Not be in TabItem,they Work Properly But,if i add they into TabItem They wont Disable Automatic.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170326.1 | Last Updated 4 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100