Xamarin.Forms ile ilk, basit uygulamayı oluşturmaya çalışıyorum.Binding ToolbarItem Tıklayın Xamarin.Forms
Bu uygulamada bir ListView ve bir Araç Çubuğu (bir NavigationPage içinde) içeren bir ContentPage'im var.
Araç Çubuğunda, tıklatıldığında bir yöntem çalıştırması gereken bir Araç Çubuğu vardır. Google’ı ince aramış olmama rağmen, işte çalışamıyorum ...
Neyi kaçırdığımı kimse anlatabilir mi?
XAML:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:constants="clr-namespace:FlashCards;assembly=FlashCards"
x:Class="FlashCards.SetsPage"
Title="Card Sets">
<ContentPage.ToolbarItems>
<ToolbarItem Name="Add" Icon="Icon-Button-Add.png" Command="{Binding CreateCommand}"></ToolbarItem>
</ContentPage.ToolbarItems>
<ListView x:Name="CardSetView">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell Text="{Binding Title}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
CodeBehind: denedim
//...
public partial class SetsPage : ContentPage
{
ObservableCollection<CardSet> sets = new ObservableCollection<CardSet>();
public Command CreateCommand { get; private set; }
public SetsPage() {
InitializeComponent();
sets.Add(new CardSet{ Title = "Test 1" });
sets.Add(new CardSet{ Title = "Test 2" });
sets.Add(new CardSet{ Title = "Test 3" });
CardSetView.ItemsSource = sets;
this.CreateCommand = new Command(async (sender) =>
{
Debug.WriteLine("Hello");
});
}
}
//...
:
- Eğer
- araç çubuğunu ve düğmesi yalnızca aracılığıyla oluşturma yukarıya bakınız neler C# (Ve bir 012 ekleyerekparametre
- Düzenli ol'
.Clicked +=
ile kod üzerinden(object sender, System.EventArgs e) => { ... }
olay dinleyicisi()
alternatif beklendiği gibi çalışmalıdır = Bu; Testimde beklendiği gibi çalışmayan – Jason
. Denedin mi? –