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

Xaml Binding

$
0
0

Hi,
Im trying to set Binding between Xaml and cs file but it doesnt work.
Can anyone help me with this?
Resharper says: Cannot resolve Symbol 'A' due to unknown DataContext.

What am I doing wrong here?
This is my Xaml:

`
<?xml version="1.0" encoding="utf-8" ?>

        <Grid Padding="5" >
          <Grid.RowDefinitions>
            <RowDefinition Height="30"></RowDefinition>

          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
    <ColumnDefinition Width="Auto"></ColumnDefinition>
          </Grid.ColumnDefinitions>

          <Label Grid.Row="0" Grid.Column="0" Text="{Binding A}" TextColor="White" LineBreakMode="NoWrap"></Label>

          <Label Grid.Row="0" Grid.Column="1" Text="{Binding a}" TextColor="White" LineBreakMode="NoWrap"></Label>

        </Grid>


`

And this is my xaml.cs :

`
namespace App.Pages
{
public partial class StartPage1
{
public StartPage1()
{
GetData();
InitializeComponent();
BindingContext =this;
}
public string A { get; set; }
public string a{ get; set; }

public void GetData(){
A="testA";
a="testa";
}

}

}
`


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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