Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This repository was archived by the owner on May 28, 2025. It is now read-only.

need to scrub the usage of applyTemplate in UIButton  #1671

Closed

Description

@yiyang-msft

we have following pattern in UIButton. In order to retrieve temlateImage/Text, we invoke xamlButton applyTemplate and hope it force load all templated parts. But this pattern is not guaranteed to work until layout happen. Currently UIButton is working but might as well be lucky. We need come up with a solid pattern to make this approach more determinstic.

On the other hand hand, a separate pattern is being used in UITextField, which utilizes onLoadedEvent. But this requires caching value which isn't idea.

  • (void)_initUIButton {
    _xamlButton = rt_dynamic_cast([self xamlElement]);
    ...
    // Force-load the template, and get the TextBlock and Image for use in our proxies.
    [_xamlButton applyTemplate];
    ...
    WXCImage* templateImage = rt_dynamic_cast([WXCImage class], [_xamlButton getTemplateChild:@"buttonImage"]);
    WXCTextBlock* templateText = rt_dynamic_cast([WXCTextBlock class], [_xamlButton getTemplateChild:@"buttonText"]);

...
}

Activity

  1. added 2 commits that reference this issue on Feb 6, 2017
    dd0eef3
    b4b4b52
  2. added a commit that references this issue on Feb 13, 2017
    87dd17b
  3. added a commit that references this issue on Feb 17, 2017
    ffe05fa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions