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:InvokeDataCommand Command="TestCompany.SubmitCommand" ></si:InvokeDataCommand>
</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, 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();
}
}
<however above="" code="" is="" not="" working="" and="" i="" getting="" the="" following="" error="" on="" my="" xaml="" page="" mode="hold">
XAMLParseException Occurred
AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 43 Position: 51]
Can you please suggest me.