Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Why almost everything is private, internal on non-virtual?

$
0
0

We love the idea of Forms. We fully understand that the included renderers are simple and in real world app there will be need to create custom ones.

We are now creating a real world app - and it seems that in almost every case when we have need to write custom renderer of something it becomes a nightmare because most of the required properties are either private, internal or can't be overridden.

The last example - I need to extend the EntryCell with TextColor property. Seems easy, right?
For iOS:

  1. The nested EntryCellTableViewCell class is private. The only was to access the UITextField is to iterate the UITableViewCell's ContentView subviews
  2. The PropertyChanged event handlers are static. OK - this might not be a big deal, since we can attach our own but then...
  3. The CellRenderer.GetRealCell is internal (arghhhh) - no way to get the native cell in custom handler.

So it seems that the only way is to use a custom ViewCell instead of renderer (which is not recommended because of performance - and seems to be totally unneeded here) or use some hacky reflection to access hidden properties. Three dirty hacks just to change the text color!

Xamarin.Forms guys - why is that? We need to make our app look good. Which means accessing and adding many properties not initially available in Forms - and this seems to be almost impossible without hacks (or reimplementing half of Forms stack) in almost every implementation we try to do :(.


Viewing all articles
Browse latest Browse all 58056

Trending Articles