0

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 ?

akirti
  • 179
  • 2
  • 15
  • From what you've posted, it looks like you are doing it right. I would try working my way back to isolate the bug -- eg, try it with a Button instead of the Telerik "rad menu, cowabunga dude" control. – McGarnagle Oct 23 '14 at 16:35
  • The same code also work for me when I removed few break point which I put during debugging. IT worked. I don't why and how this break point impact the code. But surely it does something. May Be thread issues. If anyone can put more light into this Please say. – akirti Oct 27 '14 at 19:06
  • It might be due to the time limit then (the MSDN docs state that if there is a ~x second delay between the user action and the dialog opening, then the exception will be triggered). – McGarnagle Oct 29 '14 at 18:04

0 Answers0