C
C#11mo ago
.tree

❔ 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
ero
ero11mo ago
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 method
.tree
.tree11mo ago
Ok 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
sibber
sibber11mo ago
just give it a name and use a binding
Accord
Accord11mo ago
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.