I am using a converter, as documented at https://help.syncfusion.com/wpf/datagrid/conditional-styling to conditionally format the rows in my sfDataGrid. My XAML is:
If I remove the <TabItem.Resources> cell selection works as expected. With it, the cells recolour correctly but cannot be selected - I just get the bold rectangle round the currently selected cell. If I attempt a click and drag, the bold rectangle round the cell simply moves with the mouse cursor, but no cell range selection is made.
I don't think this is the intended behaviour for the control, so I guess I must be doing something incorrectly?
TIA
Hi Peter,
We have checked the provided code snippet from our end. You are applying the CellStyle
in SfDataGrid. So, when you apply the background for GridCell, the selection is
not displayed in the UI.
However, you can overcome this problem by reducing the opacity
of the brush that you set to the GridCell background. Refer to the below
code snippet,
|
public class ParserColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var input = value as OrderInfo;
//custom condition is checked based on data.
if (input.OrderID < 1003) //Here define the Opacity for the SolidColorBrush return new SolidColorBrush(Colors.LightBlue) { Opacity=0.5};
else if (input.OrderID < 1007) //Here define the Opacity for the SolidColorBrush return new SolidColorBrush(Colors.Bisque) { Opacity = 0.5 };
else return DependencyProperty.UnsetValue; }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } |
Find the sample in the attachment.
For more information, refer to the below knowledge base documentation link:
KB Link: https://www.syncfusion.com/kb/3182/how-to-show-the-selection-of-row-cell-when-setting-the-background-for-sfdatagrid-gridcell
Regards,
Vijayarasan S
If this post is helpful, please consider Accepting it as the solution so that
other members can locate it more quickly.
Thank you so much for your reply. Yes, I can see that reducing the opacity shows the selected cells. However, I do have to compromise on my desired cell background colours.
Also, and I'm afraid I couldn't get your sample to compile, but although a selection rectangle is now shown, Ctrl+C does not copy the selected cells to the clipboard. I have:
GridCopyOption="IncludeHeaders"
SelectionMode="Extended"
SelectionUnit="Cell"
So I don't understand why the copy functionality is not working. I have another sfDataGrid in the application with the same settings but no converter and Ctrl+C works as expected there.
We have created a new thread for the query, and
the link is below.
https://www.syncfusion.com/forums/179128/unable-to-copy-the-data-when-gridcopyoption-set-as-includeheaders-in-sfdatagrid-from-179070