How to obtain the bindable text property from a label

so basically from the sdk sample provided ( on github )it can load each item and set the binding to a label like so

label.SetBinding(Label.TextProperty, "eventPicture");

i want to get the value so i can put it in another a variable to make my code work
ive tried

label.text.tostring()
label.tostring()

ive also tried

var k = label.GetValue(Label.TextProperty)
it all comes up null but when the app loads
the labels have the text in tact im lost now..... i dont know what im doing wrong

//class with the binding
public class Eventcell : ViewCell
{

     const string http = "https://s3.amazonaws.com/mywebsite.com/";
    public Eventcell()
    {
        var label = new Label
        {
            VerticalTextAlignment = TextAlignment.Center
        };
        var label2 = new Label
        {
            VerticalTextAlignment = TextAlignment.Center
        };
        var image = new Image
        {

        };


        //needs to get the location of the picture
        label.SetBinding(Label.TextProperty, "eventPicture");
        var k =label2.GetValue(Label.TextProperty);
        var picLocation = http + k +".jpg";

        image.Source = ImageSource.FromUri(new Uri(picLocation));
        label2.SetBinding(Label.TextProperty, "eventPicture");

        var layout = new StackLayout
        {
            Padding = new Thickness(20, 0, 0, 0),
            Orientation = StackOrientation.Horizontal,
            HorizontalOptions = LayoutOptions.StartAndExpand,
            Children = { label2,image }
        };

        View = layout;
    }


    protected override void OnBindingContextChanged()
    {
        View.BindingContext = BindingContext;
        base.OnBindingContextChanged();
    }

}
public AddEvent()
{
Title = "Adding New Events";

        NavigationPage.SetHasNavigationBar(this, true);

        listView = new ListView
        {
            RowHeight = 40,
            ItemTemplate = new DataTemplate(typeof(Eventcell))
        };

        listView.ItemSelected += (sender, e) =>
        {
            var contact = (Event)e.SelectedItem;
            var contactPage = new NewEventPage();
            contactPage.BindingContext = contact;
            Navigation.PushAsync(contactPage);

        };

        var layout = new StackLayout();

        layout.Children.Add(listView);
        layout.VerticalOptions = LayoutOptions.FillAndExpand;
        Content = layout;
        ToolbarItem tbi = null;
        if (Device.OS == TargetPlatform.iOS)
        {
            tbi = new ToolbarItem("+", null, () =>
            {
                var contact = new Event();
                var contactPage = new NewEventPage();
                contactPage.BindingContext = contact;
                Navigation.PushAsync(contactPage);
            }, 0, 0);
        }
        if (Device.OS == TargetPlatform.Android)
        {
            tbi = new ToolbarItem("+", "plus", () =>
            {
                var contact = new Event();
                var contactPage = new EventPage();
                contactPage.BindingContext = contact;
                Navigation.PushAsync(contactPage);
            }, 0, 0);
        }

        ToolbarItems.Add(tbi);
    }

    protected override void OnAppearing()
    {
        base.OnAppearing();
        LoadContacts().ContinueWith(task =>
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                listView.ItemsSource = task.Result;
            });
        });
    }

    private Task<List<Event>> LoadContacts()
    {
        var context = AmazonUtils.DDBContext;
        List<ScanCondition> conditions = new List<ScanCondition>();
        var search = context.ScanAsync<Event>(conditions);
        return search.GetNextSetAsync();
    }
}

help to understand would be greatly appreciated cause to me it all should work

Sign In or Register to comment.