Description
The XF activation-for-view-fetcher attempts to support:
ICanActivate
(as of a recent PR)- Pages
- Cells
- Views
The views bit is totally busted. It currently hooks into IsVisible
on the view, because that totally worked Once Upon A Time. However, IsVisible
no longer changes to false
when the view's page disappears.
I figured the best way around this is to get ahold of the view's Page
and hook into its Appeared
and Disappeared
events. If we combine that stream with another stream of IsVisible
changes, we could totally support view activation.
Alas, getting ahold of a view's Page
is impossible. More accurately, knowing when to get ahold of a view's Page
is impossible. We can always traverse up the UI tree to find the Page
, but we have no hook telling us when we should do this. There's no PageChanged
event, for example. I tried everything I could think of as an alternative. The most promising options were:
- hook into
PropertyChanged
where the property name is"Parent"
. Do this recursively all the way up the chain so that if any parent changes, we can re-determine thePage
. No dice because it doesn't always fire (seemingly when deserializing XAML). - override
OnParentChanged
and forward the event. Same problem as above.
Even if we could get one of these options to work, I suspect the performance would be woeful. What we really need is to hook into whatever mechanism it is that XF itself uses to tear down bindings. Or maybe the bindings are weak and it doesn't tear them down at all - not sure.
So for my particular use case (an app I'm trying to get into production), I had to throw my hands in the air and change view activations to be manual. That is, the containing Page
forwards activation calls onto the child view. It was ugly and time-consuming, but it worked.
Longer term I think we're going to need XF to support some kind of mechanism that tells us when a view is re-housed in a different Page
, then update our XF activation-for-view-fetcher accordingly.