Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.5 WCF Silverlight
Hi All,
 
I am working on Silverlight 3.0 with MVVM . In this,I have bind Button "Command" Property as below -
1. Bind Command
<Button x:Name="Submit" Content="Submit" ClickMode="Release"  Grid.Row="4" >
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <!--<si:CallDataMethod Method="TestCompany" Target="{Binding SubmitCommand}"/>-->
                    <si:InvokeDataCommand Command="TestCompany.SubmitCommand" ></si:InvokeDataCommand>
                    <!--<si:ShowMessageBox Caption="Thank you"
                                       Message="Thanks for trying the Example"
                                       MessageBoxButton="OK"/>
                    <si:SetProperty TargetName="t21" PropertyName="Background" Value="PaleGoldenrod"/>-->
                </i:EventTrigger>
            </i:Interaction.Triggers>
 
2. View Module -
 
private ICommand _SubmitCommand;
     public ICommand SubmitCommand
     {
         get
         {
             if (_SubmitCommand == null)
             {
                _SubmitCommand = new RelayCommand(InsertData);
             }
             return _SubmitCommand;
         }
 
     }
 
     int i = 0;
     void InsertData()
     {
 
         Proxy.InsertCompanyCompleted += new EventHandler<InsertCompanyCompletedEventArgs>(Proxy_InsertCompanyData);
         ServiceReference1.Company C = new ServiceReference1.Company()
         {
             CompanyID = CompanyID,
             CompanyName = CompanyID,
         };
         Proxy.InsertCompanyAsync(C);
         if (i == 1)
         {
             MessageBox.Show("Data Inserted Successfully");
         }
 
     }
     //  void Proxy_InsertCompanyData(object sender,InsertCompanyCompletedEventArgs e)
     void Proxy_InsertCompanyData(object sender, ServiceReference1.InsertCompanyCompletedEventArgs e)
     {
         if (e.Error == null)
         {
             i = e.Result;
         }
     }
 
3- There is one more Class Name is Relay Command as below -
public class RelayCommand:ICommand
    {
        private Func<bool> canExecute;
        private Action executeAction;
        public event EventHandler CanExecuteChanged; 
        public RelayCommand(Action executeAction,
            Func<bool> canExecute)
        {
            this.executeAction = executeAction;
            this.canExecute = canExecute;
        } 
        public RelayCommand(Action executeAction)
        {
           this.executeAction = executeAction;
            this.canExecute = () => true;
        } 
        public void RaiseCanExecuteChanged()
       {
            if (CanExecuteChanged != null)
            {
                CanExecuteChanged(this, EventArgs.Empty);
            }
        } 
        public bool CanExecute(object parameter)
         {
           return canExecute == null ? true : canExecute();
        } 
        public void Execute(object parameter)
        {
            executeAction();
        }
    }

XAMLParseException Occurred
AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 43 Position: 51]

 
Can you please suggest me.
Posted 3-Oct-12 19:29pm
Edited 3-Oct-12 22:34pm
166.9K
v2

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

  Print Answers RSS
0 OriginalGriff 540
1 Sergey Alexandrovich Kryukov 402
2 Yogesh Kumar Tyagi 384
3 Prakriti Goyal 280
4 Maciej Los 205
0 OriginalGriff 6,632
1 Sergey Alexandrovich Kryukov 5,404
2 Maciej Los 3,474
3 Peter Leow 3,299
4 DamithSL 2,495


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 4 Oct 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