Quantcast
Channel: Visio General Questions and Answers for IT Professionals forum
Viewing all articles
Browse latest Browse all 2333

Data Binding a Custom Cell in Xamarin.Forms ListView

$
0
0
public class App : Application
{
  ListView lv;
  public App()
  {
    lv = new ListView();
    // The root page of your application
    MainPage = new ContentPage
    {
      Content = new StackLayout
      {
        VerticalOptions = LayoutOptions.FillAndExpand,
        Children = {
          lv
        }
      }
    };
    MainPage.Title = "Weather";
    if (Device.OS == TargetPlatform.iOS)
    {
      MainPage.Padding = new Thickness (0, 35, 0, 0);
    }
    DisplayData();
  }
  async void DisplayData()
  {
    var wsa = new Data();
    var weather = await wsa.GetData("Knoxville, TN");
    var cellTemplate = new DataTemplate(typeof(TemperatureCell));
    lv.ItemTemplate = cellTemplate;
    lv.ItemsSource = weather.list;
  }

  protected override void OnStart()
  {        }

  protected override void OnSleep()
  {        }

  protected override void OnResume()
  {        }
}

Viewing all articles
Browse latest Browse all 2333

Trending Articles



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