Hi,
When exporting to excel I need to extract background color, border brush, border thickness from the CellValuePresenter and DataRecordPresenter. I've check in the CellExporting event arguments but haven't found a way to extract the CellValuePresenter and the DataRecordPresenter
The gold is to mimic the visual of the Grid.
Regards,
Dominik
Hello Dominik,
Thank you for your reply. I am very glad that my approach was helpful for you. Please let me know if you need any further assistance on this.
Sincerely,
Krasimir, MCPD
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
Hi Krasimir,
This solution resolve my issue,
Thanks,
Thank you for your reply and the attached sample application. I have been looking into your requirements and since you are using Bindings to the Values of the Setters, you can use a helper objet to get the value that the Binding is returning. To do that you can create a class that derives from the DependencyObject class, with one DependencyProperty in it. After doing so, you can get the Binding of the Value of the Setter and create a new Binding for the property of the DependencyObject with the same Path as the Binding of the Setter and set the Source of the new Binding. When you do that, the binding is triggered and the value of the property of the DependencyObject is the value of the Binding of the Setter. Here is how this is done, in the CellExporting event:
var bgSetter = drcaStyle
.Setters
.Where(s => s is Setter && (s as Setter).Property.Name.Equals("Background"))
.FirstOrDefault() as Setter;
if (bgSetter != null)
{
if (bgSetter.Value is Binding)
DummyDO d = new DummyDO();
BindingOperations.SetBinding(
d,
DummyDO.ValueProperty,
new Binding
Path = (bgSetter.Value as Binding).Path,
Source = record
});
SolidColorBrush brush = d.Value as SolidColorBrush;
//recordExportingArguments.cee
arguments.FormatSettings.FillPatternForegroundColor = brush.Color;
}
Here the DummyDO is the DependencyObject, and since in the style for the CellValuePResenter, the DataContext is the Record, I am setting the source to the Record itself. I have modifed the sample that you have attached, in order to show how you can implement this appraoch and also use it for the DataTriggers.
Please let me know if you need any furhter assistance on the matter.
Hi Dimi,
Thanks for the answer, here's a demo project that export a data grid to excel. The objective would be to export row and cell background and border.
Notice the comment
// Note to Dimi Gineva // The section below is common to all grids, they should be domain independent // i.e. there should be not reference to Item
Hi Dominik,
Yes you are right, Basically you can’t get the CellValuePresenter if you have virtualization. If you disable the virtualization mode then you can access the CellValuePresenter .
But I still I am not sure what kind of Style you want to access in to CellValuePresenter, if you are looking for the default styles, I guess they are initially known and you can get them as default. If you give me more details about your application, even better sample app and explain me the end goal you are trying to achieve I will try to provide you more suggestions.