Issue
I have a listview and want to bind two values from xaml. If it's possible can I get example how to do that ?
<StackLayout Spacing="0" x:Name="ExchangeStack">
<ListView x:Name="lstExchange" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<Grid BackgroundColor="#454545">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="2"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding Name}" XAlign="Center" YAlign="Center" TextColor="#2196F3" FontAttributes="Bold" FontSize="Medium" HorizontalOptions="CenterAndExpand"/>
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding Price, StringFormat='{0:F0} $'}" XAlign="Center" YAlign="Center" TextColor="#2bff00" FontAttributes="Bold" FontSize="Small" HorizontalOptions="CenterAndExpand"/>
<BoxView Color="White" HeightRequest="1" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"/>
</Grid>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
I want to bind Name and Price on one label.
Solution
Yes it is possible
<Label.Text>
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="Name" />
<Binding Path="Price" />
</MultiBinding>
</Label.Text>
https://xamgirl.com/understanding-multi-binding-in-xamarin-forms/
Answered By - Bas H
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.