❔ XAML accessing property of parent views element
I have this structure in XAML:
<RelativeLayout>
<Grid1>
<tabView>
<tabView.Item>
<MyView>
<Grid2>
<MyView2 x:Name="MyView2" IsVisible = false>
In the code behind of MyView
I want to set MyView2
's IsVisible
property to true on a button click. I tried it using Parent.Parent.Parent.Parent.FindByName<MyView2>("MyView2").IsVisible = true;
but couldnt get anything to show on button press.4 Replies
Wouldn't it be more like
Parent.Parent.Parent
and from there you need to find the child Grid2
and then the MyView2
child?
Maybe there's even something to find a parent of a specific type
Could even make an extension methodOk I was under the impression it would find the node I specified automatically. I didnt consider that I might have to specify the grid2 as well
just give it a name
and use a binding
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.