Button click not firing with Nested Views

So the issue that I am having is I have ContentView nested in a ContentPage. The ContentView has a click event associated in the codebehind. (c#). But it does not fire. I'm thinking it's due to the fact that the click event doesn't actually reach the button.

Here is my xaml



            <ScrollView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                    <!--<Button Text="Download Course" Clicked="DownloadClicked"/>-->
                    <!--<Button Text="Load Catalogue" Clicked="LoadCourses"/>-->
                <Label Text="{Binding Title}" StyleClass="pageTitle,fontColor"></Label>
                <StackLayout x:Name="Cat"></StackLayout>
                        <StackLayout x:Name="LP"></StackLayout>
                        <ActivityIndicator x:Name="CatalogueProgress" IsVisible="False" HeightRequest="20"/>

Here is the xaml for NavBarView

        <StackLayout Style="{StaticResource headerContainer}" BackgroundColor="{Binding Source={x:Static constants:Constants.HeaderColour}}">
            <Grid HorizontalOptions="FillAndExpand" RowSpacing="0" ColumnSpacing="0" BackgroundColor="{Binding Source={x:Static constants:Constants.HeaderColour}}">
                    <ColumnDefinition Width="48"/>
                    <ColumnDefinition Width="*"/>
                    <RowDefinition Height="48"/>
                <ImageButton Clicked="OpenMenu" Pressed="OpenMenu" x:Name="burger" Grid.Row="0" Grid.Column="0" Source="round_menu_white_48.png" HorizontalOptions="FillAndExpand"/>
                <ffimageloading:CachedImage Grid.Row="0" Grid.Column="1" Style="{StaticResource headerImage}" Source="{Binding Source={x:Static constants:Constants.Logo}}"></ffimageloading:CachedImage>


  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    I would urge you to clean up that XAML and do things correctly instead of this mess of x:nameing your controls, associating in code behind and handling logic in the UI layer through code behind. That's just not at all the way things are done post 2001 WinForms.

    I for one wouldn't want to assist someone in patching bad practices because that just makes it seem like its okay to do this sort of stuff. Then later I'm the bad guy because "You told me to".

    I'm reasonably confident that when you clean this up and follow proper MVVM design practices... put logic in the logic layer... handle commands in the ViewModel instead of UI events (button.click) ... and so on... That your issues will clear up on their own. Other wise its more like asking "How do I quiet the thumping of my flat tire?" when the answer is actually to change the tire, not quiet the thumping.

    Tutorial series

  • campbellmacmillancampbellmacmillan Member ✭✭

    Yes I know not the best example.

    I cleaned it up all MVVM like, used commands blah blah blah..
    Same problem. (Well the Command wasn't firing).

    After scratching my head for a few hours, I switched the ffimageloading:CachedImage to a plain old regular Image and BAM!
    It worked.. Something with the CachedImage control probably overlaying the menu image button.

    Anyways thanks for being Crusty ;)

Sign In or Register to comment.