chaosifier / TabView

TabView control for Xamarin.Forms.
MIT License
124 stars 32 forks source link

Accessing in code behind #12

Closed kaushalyacs closed 5 years ago

kaushalyacs commented 6 years ago

@chaosifier Thanks for the great controller, it really helped me.

I'm trying below sample:

                       <controls:TabViewControl Grid.Row="1"
                                             BindingContext="{Binding BindingContext, Source={x:Reference LoginPageM}}"
                                             HeightRequest="300"
                                             Padding="20"
                                             Margin="20,0,20,0">
                        <controls:TabViewControl.TabItems>
                            <x:Array Type="{x:Type controls:TabItem}">
                                <controls:TabItem HeaderText="Tab 1 title">
                                    <controls:TabItem.Content>
                                        <Label Text="Tab 1 content" x:Name="label1"/>
                                    </controls:TabItem.Content>
                                </controls:TabItem>
                                <controls:TabItem HeaderText="Tab 2 title.">
                                    <controls:TabItem.Content>
                                        <Label Text="Tab 2 content." x:Name="label2"/>
                                    </controls:TabItem.Content>
                                </controls:TabItem>
                            </x:Array>
                        </controls:TabViewControl.TabItems>
                    </controls:TabViewControl>

I want to access label1 and label2 in code behind. What I can see is they are null when debugging page constructor. I called them after InitializeComponent(); Any idea?

Thanks Kaushalya

kaushalyacs commented 6 years ago

@rjantz3 and @masiri201 guys, any idea on this? Welcome your inputs.

rjantz3 commented 6 years ago

@kaushalyacs I pushed commits to my fork of this project that fixes this problem. I have included the updated code in PR #7 as well.

kaushalyacs commented 6 years ago

@rjantz3 Great, Thanks for the fix.

chaosifier commented 5 years ago

Kudos @rjantz3 . I hope the issue is resolved.