Hi,
We are looking into upgrading our Telerik UI for WPF 2013Q1 to 2018Q3.
As part of the POC process I encountered the following blocking issue.
I need to upgrade this code to Telerik UI for WPF 2018 Q3 but wasn't able to do so after consulting the documentation available on the web.
The main issue is converting the removed\obsolete GridViewElementExportingEventArgs.Attributes["border"] and GridViewElementExportingEventArgs.Styles["background-color"] from 2013Q1 to 2018Q3.
Can you help me solve this upgrade blocking issue?
Thanks in advance
01.
private
static
RadDocument CreateDocument(RadGridView grid, PrintSettings settings)
02.
{
03.
RadDocument document =
null
;
04.
05.
using
(var stream =
new
MemoryStream())
06.
{
07.
EventHandler<GridViewElementExportingEventArgs> elementExporting = (s, e) =>
08.
{
09.
if
(e.Element == ExportElement.Table)
10.
{
11.
e.Attributes[
"border"
] =
"0"
;
12.
}
13.
else
if
(e.Element == ExportElement.HeaderRow)
14.
{
15.
if
(settings.HeaderBackground !=
null
)
16.
{
17.
e.VisualParameters
18.
e.Styles.Add(
"background-color"
, settings.HeaderBackground.ToString().Remove(1, 2));
19.
}
20.
}
21.
else
if
(e.Element == ExportElement.GroupHeaderRow)
22.
{
23.
if
(settings.GroupHeaderBackground !=
null
)
24.
{
25.
e.Styles.Add(
"background-color"
, settings.GroupHeaderBackground.ToString().Remove(1, 2));
26.
}
27.
}
28.
else
if
(e.Element == ExportElement.Row)
29.
{
30.
if
(settings.RowBackground !=
null
)
31.
{
32.
e.Styles.Add(
"background-color"
, settings.RowBackground.ToString().Remove(1, 2));
33.
}
34.
}
35.
};
36.
37.
grid.ElementExporting += elementExporting;
38.
39.
grid.Export(stream,
new
GridViewExportOptions()
40.
{
41.
Format = Telerik.Windows.Controls.ExportFormat.Html,
42.
ShowColumnFooters = grid.ShowColumnFooters,
43.
ShowColumnHeaders = grid.ShowColumnHeaders,
44.
ShowGroupFooters = grid.ShowGroupFooters
45.
});
46.
47.
grid.ElementExporting -= elementExporting;
48.
49.
stream.Position = 0;
50.
51.
document =
new
HtmlFormatProvider().Import(stream);
52.
}
53.
54.
return
document;
55.
}