Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Binding a command doesn't work.

$
0
0

Hello i am trying to bind a command which has created in my content page.
Please take a look in my example below:

```

 public partial class MainPage : ContentPage
 {
    public Command ButtonClickCommand = new Command(() =>{
            Console.WriteLine("I am pressed");
        });

    public MainPage()
    {
        InitializeComponent();
    }
}

```

    <?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:App1"
             x:Class="App1.MainPage">

    <StackLayout>
        <Button 
            Command="{Binding ButtonClickCommand}" 
            Text="button1"/>
    </StackLayout>
  </ContentPage>

Unfortunately it doesn't work. Am i miss something?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>