0

I would like to change the style of some DataGrid columns / cells (background, font weight, etc.) based on regular expressions. I have more than a few thousand rows and about 20 regular expressions to evaluate.

For the time being, I extended my model via an Enum which I evaluate in the view model via an extension method. Everything works fine but it is not efficient.

I don't really want to :

  • store the Enum in the database.
  • to evaluate the regular expressions inside the value converters because I would like to share the logic among different project (ASP.Net, etc.) Moreover, this would require to duplicate the logic for each value converter.

Is it possible to know the rows which are displayed in the view model in order to update them only (taking into account the scroll, window size, etc.)?

Otherwise, what would be a more efficient strategy?

2
  • Styling is typically done in the view, not the view model. Can't you move the converter classes to the view model library or another separate library to "share the logic". Commented Feb 26 at 14:20
  • Alright, thanks for your feedback. I've just moved all the shared logic to the value converters. The initial loading is improved, but the scrolling is slightly slowed down. I'll try to improve some regular expressions, but I actually deal with rich text and can't really compare them to constant strings. Commented Feb 26 at 16:28

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.