RadGridView 导出到 Excel 创建空文件

RadGridView export to Excel creates empty file

我有下面绑定的 RadGridView,我正在尝试导出它的内容,但它总是导致一个空的导出文件。

<telerik:RadGridView Grid.Row="0" x:Name="Logs"
                                 SelectedItem="{Binding SelectedLogEntry, Mode=TwoWay}">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn CellTemplateSelector="{StaticResource IconTemplateSelector}" IsResizable="False"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding LogLevel,Mode=OneWay}" Header="Level"
                                                CellStyle="{StaticResource PaddedCell}" MinWidth="50">
                    </telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding LogID,Mode=OneWay}" Header="LogID"
                                                SortMemberPath="LogID" SortingState="Descending" MinWidth="50"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding MachineDateTime,Mode=OneWay}"
                                                Header="Machine Time" CellStyle="{StaticResource PaddedCell}" MinWidth="150"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Occured, Mode=OneWay}" Header="Occured" MinWidth="100" CellStyleSelector="{StaticResource ColorSelector}"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding System,Mode=OneWay}" Header="System" MinWidth="50"
                                                CellStyle="{StaticResource PaddedCell}" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Mode,Mode=OneWay}" Header="Mode" MinWidth="50"
                                                CellStyle="{StaticResource PaddedCell}" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding CallingClass,Mode=OneWay}"
                                                Header="Calling Class" MinWidth="250" Width="Auto"
                                                CellStyle="{StaticResource PaddedCell}" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Message,Mode=OneWay}" Header="Message"
                                                Width="250" CellStyle="{StaticResource PaddedCell}" />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Exception,Mode=OneWay}" Header="Exception" Width="350" CellStyle="{StaticResource PaddedCell}" />  
                </telerik:RadGridView.Columns>                      
</telerik:RadGridView>

导出日志的方法:

  private void ExportLogs()
        {
            using (var stream = File.Create(filepath))
            {
                Logs.Export(stream,
                 new GridViewExportOptions()
                 {
                     Format = ExportFormat.ExcelML,
                     ShowColumnHeaders = true,
                     ShowColumnFooters = false,
                     ShowGroupFooters = false,
                 });    

            }
        }

没有收到异常或警告。 任何帮助,将不胜感激。谢谢。

我的代码的问题是,由于多线程,GridView 是从非UI 线程访问的,这导致 GridView 的内容处于不可访问状态。所以我尝试从 UI 线程调用 Export 函数,它按预期工作。