Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

Binding not working in titleview using xamarin.forms ios but works in android

Open prakash-malodiya opened this issue 7 years ago • 5 comments
trafficstars

I am using xamarin.forms (3.3.0.967583) version for developing application. In xamarin.forms iOS application I am unable to bind property from MVVM to xaml in titleview. But its working in Android application. I am not going to attach my code. I also see other related issues but not helping. See below sample code.

<NavigationPage.TitleView>
    <StackLayout HorizontalOptions="Start" 
        VerticalOptions="Center" 
        Margin="0" 
        Padding="{OnPlatform iOS='25,0,0,0', Android=0}">        
        <Label 
            Text="{Binding SelectedProduct.Title, 
            Mode=TwoWay}"
            TextColor="White" 
            FontSize="{StaticResource LargeFontSize}" 
            FontFamily="{StaticResource OpenSansRegular}" 
            VerticalTextAlignment="Center" />
    </StackLayout>
</NavigationPage.TitleView>

prakash-malodiya avatar Nov 23 '18 06:11 prakash-malodiya

@tp16190 please use the template for filing new issues.

StephaneDelcroix avatar Nov 23 '18 08:11 StephaneDelcroix

FYI: I just tested with latest version 3.4, it's not show on Android platform, iOS haven't tested yet.

KennyDizi avatar Nov 23 '18 09:11 KennyDizi

TitleView.zip

@tp16190 I've attached a repro showing binding working though I noticed that the layout width on iOS doesn't update if the width changes.

If you use a grid or set the stacklayout to a full width then binding should work. Let me know if that appears to be your issue

PureWeen avatar Jan 07 '19 17:01 PureWeen

I'm seeing this problem in UWP. This is not a height/width issue as there is plenty of room and I can see whether the label is with enable selection/display layout adorner options. The value being bound is also being bound elsewhere on the page and displays correctly.

    <NavigationPage.TitleView>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Label Grid.Row="0" Text="Settings"/>
            <Label Grid.Row="1" Text="{Binding MyProperty, Mode=OneWay}"/>
        </Grid>
    </NavigationPage.TitleView>

csuzw avatar Jan 14 '19 15:01 csuzw

I had the same thing happen to me - I'm on VS 2019, Windows. The first page I visited, displayed the correct page title. After that, it was grabbing the Title attribute from the menu item out of the Master Page. I don't know how it managed that, but I solved it by creating a property in my TitleContentView, and assigning it in the XAML for each content page that used it.

llandru54 avatar Jan 14 '20 18:01 llandru54