xaml - Xamarin C# Double Binding Source -
is possible have 2 sources of binding? element such cellview?
i searched , tried several possibilities had in mind without able want do. seems simple however..
let says have page (i put simple code, bit long, not hard):
mainpage.cs
public partial class courseshistory : contentpage { // course it's element "data template" listview private class course { public string date { get; set; } public string destination { get; set; } private string _price; public string price { { return this._price; } set { this._price = "€" + value; } } } // fontattribute it's other element not set itemssource, used cell fontfamily ask, fontsize etc private class fontattributes { public string moon_family_alien_bold { get; set; } .... public fontattributes() { .... } } public fontattributes fontattr; public courseshistory() { fontattr = new fontattributes(); initializecomponent(); initlist(); } private void initlist() { observablecollection<course> courses = new observablecollection<course>(); listviewhistory.itemssource = courses; courses.add(new course() { date = "1 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "2 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "3 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "4 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "5 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "6 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "7 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "8 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "9 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "10 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "11 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "12 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "13 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "14 novembre 1995", destination = "le mans", price = "23.11" }); courses.add(new course() { date = "15 novembre 1995", destination = "le mans", price = "23.11" }); } }
and xaml mainpage.xaml.cs
<?xml version="1.0" encoding="utf-8" ?> <contentpage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:class="pages.courseshistory"> <absolutelayout> <listview x:name="listviewhistory" backgroundcolor="white" rowheight="50" absolutelayout.layoutbounds="0.5,0.5,1,1" absolutelayout.layoutflags="all"> <listview.itemtemplate> <datatemplate> <viewcell> <absolutelayout>
the list bind observablecollection how can access fontattr not bind?
<label fontfamily="{binding path=how_can_i_access_fontattr??}" text="{binding date}" textcolor="black" fontsize="14" verticaltextalignment="center" horizontaltextalignment="center" absolutelayout.layoutbounds="0, 0.5, 0.3, 1" absolutelayout.layoutflags="all"/> <label text="{binding destination}" textcolor="black" fontsize="14" verticaltextalignment="center" horizontaltextalignment="center" absolutelayout.layoutbounds="0.5, 0.5, 0.5, 1" absolutelayout.layoutflags="all"/> <label text="{binding price}" textcolor="black" fontsize="14" verticaltextalignment="center" horizontaltextalignment="center" absolutelayout.layoutbounds="1, 0.5, 0.2, 1" absolutelayout.layoutflags="all"/> </absolutelayout> </viewcell> </datatemplate> </listview.itemtemplate> </listview> </absolutelayout> </contentpage>
thank read , !
in xaml, should specify string format display double value.
<stacklayout orientation="horizontal"> <label x:name="name_label_meetinglocation1" text="{binding latitude , stringformat='{0:0.0000}'}"/> </stacklayout>
Comments
Post a Comment