1
votes

I've just started with Firemonkey, and still have a lot to learn with regards to the usage of styles, but there is something I can't get figure out.

I've learned how to simulate a TListView using styles. So I've made a style which adds a progress bar to a list item, let's call this ListItemStyleProgressBar.

Now I'd like two ListView instances on my form, one where the font of the TListItem is red, and one where the font is blue. How to achieve this? Can I make an style which 'inherits' from ListItemStyleProgressBar (ListItemStyleProgressBarRed)?

Next to that, I'd like to be able to 'style' these two listview instances, so have a style which shows a light back and a style which shows a dark back.

What confuses me is it seems the styling is needed to add functionality (add a TProgressBar to a TListItem) as well as to do styling for this added functionality.

Can anyone tell me what I'm missing here?

1

1 Answers

0
votes

No. There is no inheritance mechanism for styles. There are two ways to solve your problem:

1) Create two (or more) very similar styles to represent each 'look'. 2) Make the changes at run-time either with the OnApplyStyleLookup method or, if you have a custom control, by overriding the ApplyStyle method.

In the latter case you'll need something like this:

procedure TMyClass.ApplyStyle;
var O: TFMXObject;
begin
  O := FindStyleResource('background');
  if O is TRectangle then
    TRectangle(O).Fill.Color := claRed;
end;