FindStyleResource fails to find nested FireMonkey style controls if their parent is TStyledControl descendant.

FindStyleResource fails to find nested FireMonkey style controls if their parent is TStyledControl descendant.

https://stackoverflow.com/q/52478699/4267244

I have a solution by iterating through children myself.

But I would still like to know the following:

1. Is this behavior a bug or a feature?
2. If it is not a bug, why FindStyleResource works the way it does?
3. Am I doing this completely the wrong way and some other mechanism is available?

https://stackoverflow.com/q/52478699/4267244

Comments

  1. I think that is the way the style designer works and the styling of controls are based of. What exactly you want to make and the base style objects are not enough and you used TSpeedButton instead?

    ReplyDelete
  2. Panagiotis Drivilas Problem is not in TSpeedButton itself, but in nesting controls. And without nesting you cannot create more complex layouts. Or in other words, you can create them, but you cannot easily tweak behavior at runtime without creating zillion styles.

    Other solution is using frames, but that approach also has its flaws.

    ReplyDelete
  3. Dalija Prasnikar I posted new code on stackoverflow

    ReplyDelete
  4. Allow me to abuse this post to re-rant about the removal of BindingNames. They provided an excellent way to access nested controls, and the use of the StyleName property to identify every single nested control is just wrong. Nested controls are very rarely styles themselves, just style components.

    ReplyDelete
  5. John Kouraklis Yes, this one works. But it is not a general solution, it is just something that can be applied to this particular example. In real life there may be more TPath (or some other type) controls under same parent.

    ReplyDelete
  6. Dominique Willems I am late to the party. I never knew there were BindingNames. But, reading your comment, it hit me why styled controls have trouble using StyleName to locate things. If it is not actual style... no wonder.

    I don't have time at the moment... I will go back to this next week. Maybe I figure (or someone else) the proper way to use styles... maybe I will just fallback to using frames.

    No matter what I choose, the whole thing is just either too slow, or too complicated to use.

    Correction, it is just slow any way you do it...

    ReplyDelete
  7. You can also use ClassNameIs to find redpath

    ReplyDelete

Post a Comment