I have BindableLayout, that binded to ViewModel property (which is actually a subclass), but inside this layout i'm trying to bind Command to VM another property. How can i specify property for binding in this case?
XAML code:
<Grid BindableLayout.ItemsSource="{Binding ActualValues}"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="0">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Frame Margin="{Binding Margin}">
<Entry TabIndex="{Binding Id}"
Text="{Binding Value}"
Placeholder="{Binding Placeholder}"
Style="{StaticResource EntryStyle}">
<Entry.Behaviors>
<behaviors:EntryCompletedBehavior Command="{Binding EntryCompletedCommand}"/>
</Entry.Behaviors>
</Entry>
</Frame>
</DataTemplate>
</BindableLayout.ItemTemplate>
</Grid>
You could set the binding path in xaml
in xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:xxx"
x:Class="xxx.MainPage"
x:Name="page" // set name of ContentPage
>
Command="{Binding Source={x:Reference page} , Path=BindingContext.xxxCommand}"
xxxCommand is an ICommand which been defined in VM .
Related
The above header refers.
I would like to make this change so I can implement expanding lists (whereby my some of my list of items could have sub-items that can appear and disappear when you tap on their parent item).
But, when I am trying to test the app, a hitherto hidden page appeared with several new errors. I now know this file is auto-generated.
How do I successfully convert a working collectionview code to listview?
The collection View code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Abuse_Alert.Views.ItemsPage"
Title="{Binding Title}"
xmlns:local="clr-namespace:Abuse_Alert.ViewModels"
xmlns:model="clr-namespace:Abuse_Alert.Models"
x:Name="BrowseItemsPage">
<ContentPage.ToolbarItems>
<!--
<ToolbarItem Text="Add" Command="{Binding AddItemCommand}" />
-->
</ContentPage.ToolbarItems>
<!--
x:DataType enables compiled bindings for better performance and compile time validation of binding expressions.
https://learn.microsoft.com/xamarin/xamarin-forms/app-fundamentals/data-binding/compiled-bindings
-->
<RefreshView x:DataType="local:ItemsViewModel" Command="{Binding LoadItemsCommand}" IsRefreshing="{Binding IsBusy, Mode=TwoWay}">
<CollectionView x:Name="ItemsListView"
ItemsSource="{Binding Items}"
SelectionMode="None" IsGrouped="False">
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout Padding="10" x:DataType="model:Item">
<Label Text="{Binding Text}"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding Description}"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<StackLayout.GestureRecognizers>
<TapGestureRecognizer
NumberOfTapsRequired="1"
Command="{Binding Source={RelativeSource
AncestorType={x:Type local:ItemsViewModel}}, Path=ItemTapped}"
CommandParameter="{Binding .}">
</TapGestureRecognizer>
</StackLayout.GestureRecognizers>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</RefreshView>
</ContentPage>
This is the ListView Code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Abuse_Alert.Views.ItemsPage"
Title="{Binding Title}"
xmlns:local="clr-namespace:Abuse_Alert.ViewModels"
xmlns:model="clr-namespace:Abuse_Alert.Models"
x:Name="BrowseItemsPage">
<ContentPage.ToolbarItems>
<!--
<ToolbarItem Text="Add" Command="{Binding AddItemCommand}" />
-->
</ContentPage.ToolbarItems>
<!--
x:DataType enables compiled bindings for better performance and compile time validation of binding expressions.
https://learn.microsoft.com/xamarin/xamarin-forms/app-fundamentals/data-binding/compiled-bindings
-->
<Grid>
<StackLayout x:Name="local:ItemsViewModel" Padding="1,0,1,0">
<ListView x:Name="ItemsListView"
BackgroundColor="White"
IsGroupingEnabled="True"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
ItemsSource="{Binding Items}"
RefreshCommand="{Binding LoadItemsCommand}"
SelectionMode="None"
>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" x:DataType="model:Item">
<Label Text="{Binding Text}"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding Description}"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<StackLayout.GestureRecognizers>
<TapGestureRecognizer
NumberOfTapsRequired="1"
Command="{Binding Source={RelativeSource AncestorType={x:Type local:ItemsViewModel}}, Path=ItemTapped}"
CommandParameter="{Binding .}">
</TapGestureRecognizer>
</StackLayout.GestureRecognizers>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</Grid>
</ContentPage>
This is the correct auto-generated file (with CollectionView):
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: global::Xamarin.Forms.Xaml.XamlResourceIdAttribute("AbuseAlert.Views.ItemsPage.xaml", "Views/ItemsPage.xaml", typeof(global::Abuse_Alert.Views.ItemsPage))]
namespace Abuse_Alert.Views {
[global::Xamarin.Forms.Xaml.XamlFilePathAttribute("Views\\ItemsPage.xaml")]
public partial class ItemsPage : global::Xamarin.Forms.ContentPage {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
private global::Xamarin.Forms.ContentPage BrowseItemsPage;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
private global::Xamarin.Forms.CollectionView ItemsListView;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
private void InitializeComponent() {
global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(ItemsPage));
BrowseItemsPage = global::Xamarin.Forms.NameScopeExtensions.FindByName<global::Xamarin.Forms.ContentPage>(this, "BrowseItemsPage");
ItemsListView = global::Xamarin.Forms.NameScopeExtensions.FindByName<global::Xamarin.Forms.CollectionView>(this, "ItemsListView");
}
}
}
This is the auto-generated file (with listview):
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: global::Xamarin.Forms.Xaml.XamlResourceIdAttribute("AbuseAlert.Views.ItemsPage.xaml", "Views/ItemsPage.xaml", typeof(global::Abuse_Alert.Views.ItemsPage))]
namespace Abuse_Alert.Views {
[global::Xamarin.Forms.Xaml.XamlFilePathAttribute("Views\\ItemsPage.xaml")]
public partial class ItemsPage : global::Xamarin.Forms.ContentPage {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
private global::Xamarin.Forms.ContentPage BrowseItemsPage;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
private global::Xamarin.Forms.StackLayout local:ItemsViewModel;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
private global::Xamarin.Forms.ListView ItemsListView;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "2.0.0.0")]
private void InitializeComponent() {
global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(ItemsPage));
BrowseItemsPage = global::Xamarin.Forms.NameScopeExtensions.FindByName<global::Xamarin.Forms.ContentPage>(this, "BrowseItemsPage");
local:ItemsViewModel = global::Xamarin.Forms.NameScopeExtensions.FindByName<global::Xamarin.Forms.StackLayout>(this, "local:ItemsViewModel");
ItemsListView = global::Xamarin.Forms.NameScopeExtensions.FindByName<global::Xamarin.Forms.ListView>(this, "ItemsListView");
}
}
}
These are the errors when i changed the code to listview:
Severity Code Description Project File Line Suppression State
Error CS1003 Syntax error, ',' expected AbuseAlert D:\MobileApps\SVr\SVReporting - Backup\SV Reporting\obj\Debug\netstandard2.0\Views\ItemsPage.xaml.g.cs 23 Active
Error CS1002 ; expected AbuseAlert D:\MobileApps\SVr\SVReporting - Backup\SV Reporting\obj\Debug\netstandard2.0\Views\ItemsPage.xaml.g.cs 23 Active
Error CS1519 Invalid token ';' in class, record, struct, or interface member declaration AbuseAlert D:\MobileApps\SVr\SVReporting - Backup\SV Reporting\obj\Debug\netstandard2.0\Views\ItemsPage.xaml.g.cs 23 Active
Error CS1519 Invalid token ';' in class, record, struct, or interface member declaration AbuseAlert D:\MobileApps\SVr\SVReporting - Backup\SV Reporting\obj\Debug\netstandard2.0\Views\ItemsPage.xaml.g.cs 23 Active
Error CS0006 Metadata file 'D:\MobileApps\SVr\SVReporting - Backup\SV Reporting\obj\Debug\netstandard2.0\ref\AbuseAlert.dll' could not be found AbuseAlert.Android D:\MobileApps\SVr\SVReporting - Backup\SV Reporting.Android\CSC 1 Active
Error IDE1007 The name 'ItemsViewModel' does not exist in the current context. AbuseAlert D:\MobileApps\SVr\SVReporting - Backup\SV Reporting\obj\Debug\netstandard2.0\Views\ItemsPage.xaml.g.cs 23 Active
Error CS0103 The name 'ItemsViewModel' does not exist in the current context AbuseAlert D:\MobileApps\SVr\SVReporting - Backup\SV Reporting\obj\Debug\netstandard2.0\Views\ItemsPage.xaml.g.cs 32 Active
Warning CS0164 This label has not been referenced AbuseAlert D:\MobileApps\SVr\SVReporting - Backup\SV Reporting\obj\Debug\netstandard2.0\Views\ItemsPage.xaml.g.cs 32 Active
This is the ListView code that is not properly displaying the Item & its related description. But if I reduce Item to size 10 & Description to size 8, both will appear correctly but will appear too small.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Abuse_Alert.Views.ItemsPage"
Title="{Binding Title}"
xmlns:local="clr-namespace:Abuse_Alert.ViewModels"
xmlns:model="clr-namespace:Abuse_Alert.Models"
x:Name="BrowseItemsPage">
<ContentPage.ToolbarItems>
<!--
<ToolbarItem Text="Add" Command="{Binding AddItemCommand}" />
-->
</ContentPage.ToolbarItems>
<!--
x:DataType enables compiled bindings for better performance and compile time validation of binding expressions.
https://learn.microsoft.com/xamarin/xamarin-forms/app-fundamentals/data-binding/compiled-bindings
-->
<RefreshView x:DataType="local:ItemsViewModel" Command="{Binding LoadItemsCommand}" IsRefreshing="{Binding IsBusy, Mode=TwoWay}">
<ListView x:Name="ItemsListView"
BackgroundColor="White"
IsGroupingEnabled="false"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsBusy, Mode=TwoWay}"
ItemsSource="{Binding Items}"
HasUnevenRows="True"
RowHeight="48"
SelectionMode="None"
>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10" x:DataType="model:Item" VerticalOptions="FillAndExpand" Orientation="Vertical">
<Label Text="{Binding Text}" TextColor="Black"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemTextStyle}"
FontSize="16" />
<Label Text="{Binding Description}" TextColor="Black"
LineBreakMode="NoWrap"
Style="{DynamicResource ListItemDetailTextStyle}"
FontSize="13" />
<StackLayout.GestureRecognizers>
<TapGestureRecognizer
NumberOfTapsRequired="1"
Command="{Binding Source={RelativeSource AncestorType={x:Type local:ItemsViewModel}}, Path=ItemTapped}"
CommandParameter="{Binding .}">
</TapGestureRecognizer>
</StackLayout.GestureRecognizers>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</RefreshView>
</ContentPage>
this should not be difficult
<ListView x:Name="ItemsListView" ItemsSource="{Binding Items}" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
.. StackLayout goes here ..
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
I am having issues binding the values of a string[] to the DataTemplate of a BindableLayout. I have recreated the issue in the AboutPage of the Shell Flyout Template.
AboutPage.xaml
<ContentPage.BindingContext>
<vm:AboutViewModel />
</ContentPage.BindingContext>
<StackLayout VerticalOptions="Center"
Padding="20"
BindableLayout.ItemsSource="{Binding Data}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label FontSize="Large"
Text="{Binding .}"
BackgroundColor="PowderBlue"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
AboutViewModel.cs
namespace App2.ViewModels
{
public class AboutViewModel : BaseViewModel
{
private string[] _data;
public string[] Data
{
get
{
return _data;
}
set
{
if (_data != value)
{
_data = value;
OnPropertyChanged();
}
}
}
public AboutViewModel()
{
Title = "About";
Data = new string[] { "One", "Two", "Three" };
}
}
}
When the page first opens, the the correct number of labels are there but without any text.
If I edit the Text="{Binding .}" the binding works after Xaml Hot Reload.
Why on earth are the strings not being displayed in the first place when they're clearly not empty or null?
I have solved this problem in an unexpected way. Simply by moving the DataTemplate into its own file, this problem goes away. Can someone please explain to me why this works? My new code produces two StackLayouts side by side, bound to the same data but only the Stackview on the right, with its DataTemplate defined elsewhere as ListItemView.xaml shows the data when the app is run. The StackView on the left has empty Labels at first, then after I delete the full-stop (.) from Text="{Binding .}" and replace it, Xaml Hot Reload runs and the strings are displayed.
ListItemView.xaml
<DataTemplate xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App2.Views.ListItemView">
<Label FontSize="Large"
Text="{Binding ., Mode=OneWay}"
BackgroundColor="PowderBlue"/>
</DataTemplate>
AboutPage.xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App2.Views.AboutPage"
xmlns:vm="clr-namespace:App2.ViewModels"
xmlns:views="clr-namespace:App2.Views"
Title="{Binding Title}"
x:DataType="vm:AboutViewModel">
<ContentPage.BindingContext>
<vm:AboutViewModel />
</ContentPage.BindingContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<StackLayout VerticalOptions="Center"
Padding="20"
BindableLayout.ItemsSource="{Binding Data}"
Grid.Column="0">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label FontSize="Large"
Text="{Binding ., Mode=OneWay}"
BackgroundColor="PowderBlue"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
<StackLayout VerticalOptions="Center"
Padding="20"
BindableLayout.ItemsSource="{Binding Data}"
Grid.Column="1">
<BindableLayout.ItemTemplate>
<views:ListItemView />
</BindableLayout.ItemTemplate>
</StackLayout>
</Grid>
</ContentPage>
I solved this in a similar way. I did create a separate DataTemplate, but not in its own file. The addition I made was to add an x:DataType attribute.
<DataTemplate x:Key="myLabel" x:DataType="x:String">
<StackLayout>
<Label Text="{Binding .}" />
</StackLayout>
</DataTemplate>
I'm stuck in this problem in first try to use xamarin forms.
I'm trying to set DataTemplateSelector for CollectionView in Xamarin forms but I get this error "LoadTemplate should not be null".
It working without problems if I used ListView.
this is my XAML Code :
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:viewmodel="clr-namespace:JisrWallet.ViewModels"
xmlns:common="clr-namespace:JisrWallet.Common"
x:Class="JisrWallet.views.Layout.CardsPage"
xmlns:views="clr-namespace:SuaveControls.Views;assembly=SuaveControls.FloatingActionButton"
BackgroundColor="{StaticResource lightGray}">
<ContentPage.Resources>
<ResourceDictionary>
<common:IntColorToHexConverter x:Key="colorConverter"/>
<common:PrefixValueConverter x:Key="prefixConverter"/>
<DataTemplate x:Key="existCardTemplate">
<StackLayout Margin="2">
<Image Source="{Binding StoreImageUrl}"
Aspect="AspectFill"
HeightRequest="120"
BackgroundColor="{Binding CardColor, Converter={StaticResource colorConverter}}"/>
</StackLayout>
</DataTemplate>
<DataTemplate x:Key="newCardTemplate">
<StackLayout BackgroundColor="{Binding CardColor, Converter={StaticResource colorConverter}}">
<Label Text="{Binding CardName, Converter={StaticResource prefixConverter}, ConverterParameter=1}"
HeightRequest="120"
HorizontalOptions="Center"
VerticalOptions="Center"
VerticalTextAlignment="Center"
TextColor="White"/>
<Label Text="{Binding CardName}"
FontAttributes="Bold"
BackgroundColor="{Binding CardColor, Converter={StaticResource colorConverter}}"
TextColor="{StaticResource whiteColor}"
HorizontalTextAlignment="Center"/>
<BoxView HeightRequest="2" BackgroundColor="White"/>
</StackLayout>
</DataTemplate>
<common:CardItemTemplateSelector x:Key="cardItemTemplateSelector"
ExistCardTemplate="{StaticResource existCardTemplate}"
NewCardTemplate="{StaticResource newCardTemplate}"/>
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout>
<StackLayout.BindingContext>
<viewmodel:CardsViewModel/>
</StackLayout.BindingContext>
<CollectionView x:Name="collectionView"
ItemsSource="{Binding Cards}"
ItemTemplate="{StaticResource newCardTemplate}"
SelectionMode="Single"
SelectionChanged="CollectionView_SelectionChanged">
<CollectionView.ItemsLayout >
<GridItemsLayout Orientation="Vertical" Span="2" />
</CollectionView.ItemsLayout>
</CollectionView>
<views:FloatingActionButton Image="ic_add_white"
ButtonColor="{StaticResource AccentColor}"
WidthRequest="56"
HeightRequest="56"
HorizontalOptions="End"
VerticalOptions="CenterAndExpand"
Margin="8"
Clicked="FloatingActionButton_Clicked"/>
</StackLayout>
</ContentPage>
I can't figure out the problem. Can anyone help me please ?
you define the DataTemplateSelector in your <ResourceDictionary>
<ResourceDictionary>
...
<common:CardItemTemplateSelector x:Key="cardItemTemplateSelector"
ExistCardTemplate="{StaticResource existCardTemplate}"
NewCardTemplate="{StaticResource newCardTemplate}"/>
</ResourceDictionary>
you could use it in your CollectionView like this:
<CollectionView>
...
ItemTemplate="{StaticResource cardItemTemplateSelector}"
</CollectionView>
more info refer to link:DataTemplateSelector
I have ListView with ViewCell and it's ViewCell contains Label with huge text. How can I make an auto-height ViewCell???
Screenshot of issue
My XAML code:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Physis.Movements_And_Interactions_Page" xmlns:local="clr-namespace:Physis">
<ContentPage.ToolbarItems>
<ToolbarItem x:Name="settings" Text="{Binding settings_text}" Clicked="Handle_Clicked"/>
</ContentPage.ToolbarItems>
<ContentPage.Content>
<StackLayout Margin="20,35,20,20" x:Name="Main_View2" >
<ListView x:Name="Main_Menu" ItemsSource="{Binding Planets}" ItemSelected="Handle_ItemSelected" ItemTapped="Handle_ItemTapped" BackgroundColor="{DynamicResource Key=backgroundColor}" SeparatorColor="{DynamicResource Key=textColor}">
<ListView.ItemTemplate>
<DataTemplate >
<ViewCell >
<StackLayout Orientation="Vertical" >
<Label Text="{Binding Name}" StyleClass="Body"/>
<Label Text="{Binding Description}" StyleClass="Body"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout >
</ContentPage.Content>
Thanks everyone!
Set HasUnevenRows="true" on your ListView. See documentation here https://learn.microsoft.com/en-us/dotnet/api/Xamarin.Forms.ListView.HasUnevenRows?view=xamarin-forms
Hello I have an app i'm doing in xamrian forms and I have a card styled list view. I want to be able to add 3 buttons underneath the listview one on the left one in the center and one on the right
here's my xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App.HomePage">
<ListView x:Name="listView" HasUnevenRows="true" ItemSelected="OnItemSelected">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Frame Padding="0,0,0,8" BackgroundColor="#d2d5d7">
<Frame.Content>
<Frame Padding="15,15,15,15" OutlineColor="Gray" BackgroundColor="White">
<Frame.Content>
<StackLayout Padding="20,0,0,0" Orientation="Horizontal" HorizontalOptions="CenterAndExpand">
<Image
HorizontalOptions="StartAndExpand"
Source="{Binding Image}" />
<Label Text="{Binding Name}"
TextColor="#69add1"
FontFamily="OpenSans-Light"
FontSize="24"/>
</StackLayout>
</Frame.Content>
</Frame>
</Frame.Content>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
How would I go about doing this in xaml?
Thank's in advance! :)
Try this:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Sandbox_Forms"
x:Class="Sandbox_Forms.MainPage">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ListView Grid.Row="0" BackgroundColor="Aqua">
<!-- Add bindings and data template -->
</ListView>
<StackLayout Orientation="Horizontal" Grid.Row="1">
<Button Text="Button1" HorizontalOptions="FillAndExpand"/>
<Button Text="Button2" HorizontalOptions="FillAndExpand"/>
<Button Text="Button3" HorizontalOptions="FillAndExpand"/>
</StackLayout>
</Grid>
</ContentPage>
This will limit your ListView to only fill the space that your buttons do not occupy. The output should look something like this:
<StackLayout>
<ListView>
...
</ListView>
<StackLayout Orientation="Horizontal">
<Button ... />
<Button ... />
<Button ... />
</StackLayout>
</StackLayout>