Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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
ompcj4u883
Comments
Jason Gleim at 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 at 4-Nov-12 14:44pm
   
Hi
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 :
http://ompc.ir/MVVMTestApplication.zip

1 solution

Rate this: bad
good
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">
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:vm="clr-namespace:MVVMTestApplication.ViewModels"
             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.
  Permalink  

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

  Print Answers RSS
0 Marcin Kozub 310
1 OriginalGriff 248
2 Sergey Alexandrovich Kryukov 215
3 Richard MacCutchan 202
4 Praneet Nadkar 197
0 OriginalGriff 8,048
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 4 Nov 2012
Copyright © CodeProject, 1999-2014
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