I have a Button in the view:
<Button Grid.Row="0" Grid.Column="1" Content="Export to CSV "
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="2,2,20,2" Style="{StaticResource ExportButton}"
Command="{Binding ExportToExcelCommand}"
CommandParameter="{TelerikGrid}"
/>
Now I have the ExportCommand in my ViewModel as :
private RelayCommand _exportToExcelCommand;
public ICommand ExportToExcelCommand
{
get
{
if (_exportToExcelCommand == default(RelayCommand))
{
_exportToExcelCommand = new RelayCommand(ExportToExcel, CanExport);
}
return _exportToExcelCommand;
}
}
private void ExportToExcel(Object param)
{
try
{
//ToDo: Update With Command Parameters
RadGridView gdv = new RadGridView();
using (Stream stream = dialog.OpenFile())
{
gdv.Export(Columns);
}
}
catch (FaultException ex)
{
var faultMessage = ex.Reason.GetMatchingTranslation().Text + "/n" + ex.StackTrace;
}
}
Now I am creating a new instance of RadGridView:
RadGridView gdv = new RadGridView();
But instead I want to assign gdv from the value that is passed as CommandParameter from XAML