在我的1个屏幕中,我有一个RadGridView& RadMenu。从1 RadMenuItem我必须允许用户将此网格数据保存到Excel。所以我有一个Fires& amp;将RadGridView作为CommandParameter。一切都很好,直到这里。但是在我的代码中,当我尝试打开SaveFileDialog时,它给了我安全问题&代码中断。
我尝试了像这个例子的代码 http://demos.telerik.com/silverlight/#GridView/ExportingExcelML
我的ViewModel与示例代码
中的相同我的xaml代码就像这样
.....
<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>
我收到此错误:
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:
我的应用是Prism 4,Silverlight 5&amp; Telerik控制。有关在MVVM parttern中使用FileOpenDialog的任何帮助吗?