In my 1 screen I have a RadGridView & RadMenu. From 1 RadMenuItem I have to allow user to save this Grid Data to Excel. So I have a command which Fires & take RadGridView as a CommandParameter. Everything goes fine till here. But in my code when I try to Open SaveFileDialog it gives me issue for security & Code breaks.
I tried my code like this example http://demos.telerik.com/silverlight/#GridView/ExportingExcelML
my ViewModel is same like in example code
My xaml Code is like this
.....
<telerik:RadMenuItem Header="Excel" Command="{Binding ExportExcelRouteDataCommand}" CommandParameter="{Binding ElementName=RouteGridView}">
...
</telerik:RadGridView>
<telerik:RadDataPager HorizontalAlignment="Stretch"
Grid.Row="2"
Grid.Column="0"
VerticalAlignment="Top"
x:Name="RoutesDataPager"
PageSize="{Binding PageSize,Mode=TwoWay}" FontSize="12"
BorderThickness="1,0,1,1"
Source="{Binding AllRoutesItemSource}"
DisplayMode="All"/>
</Grid>
I'm getting this Error :
System.Security.SecurityException was unhandled by user code
Message=Dialogs must be user-initiated.
StackTrace:
at System.Windows.Controls.SaveFileDialog.ShowDialogInternal(Window owner)
at System.Windows.Controls.SaveFileDialog.ShowDialog()
at Delasoft.Hpms.Module.Routes.ViewModel.RoutesDashBoardViewModel.Export(Object parameter)
at Delasoft.Hpms.Module.Routes.ViewModel.RoutesDashBoardViewModel.OnExportRouteData(Object param)
at Telerik.Windows.Controls.DelegateCommand.Execute(Object parameter)
at Telerik.Windows.Controls.RadMenuItem.ExecuteCommand()
at Telerik.Windows.Controls.RadMenuItem.OnClickImpl()
at Telerik.Windows.Controls.RadMenuItem.OnClick()
at Telerik.Windows.Controls.RadMenuItem.ClickItem()
at Telerik.Windows.Controls.RadMenuItem.HandleMouseUp()
at Telerik.Windows.Controls.RadMenuItem.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)
InnerException:
My application is in Prism 4, Silverlight 5 & Telerik controls. Any help for using FileOpenDialog in MVVM parttern ?