Note that there are some explanatory texts on larger screens.

plurals
  1. POData binding / populate items in listbox in windows phone
    primarykey
    data
    text
    <p>i have two separate classes namely:</p> <pre><code> public class Floor { private string fname; public Floor(string name) { fname = name; } public int FName { set { fname = value; } get { return fname; } } } public class Building { List&lt;Floor&gt; floors; string _bName; public Building(string bname) { _bName = bname; floors = new List&lt;Floors&gt;(); for(int i = 0; i &lt; 3; i++) { floors.Add(new Floor("floor" + (i + 1))); } } public string BName { set{ _bName = value; } get{ return _bName; } } public List&lt;Floor&gt; Floors { set { floors = value; } get { return floors; } } } </code></pre> <p>in my XAML (MainPage.xaml):</p> <pre><code>&lt;ListBox x:Name="lstBuilding" Background="White" Foreground="Black"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Orientation="Horizontal" Margin="10,0,0,15"&gt; &lt;StackPanel&gt; &lt;TextBlock Text="{Binding Path=BName }" /&gt; &lt;/StackPanel&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p>and in my XAML.cs (MainPage.xaml.cs)</p> <pre><code>ObservableCollection&lt; Building &gt; buildings = new ObservableCollection&lt; Building&gt;(); for(int i = 0; i &lt; 2; i++) { buildings.Add(new Building("building" + (i + 1))); } lstBuilding.ItemsSource = buildings </code></pre> <p>Here's the question:</p> <p>how can i access FName inside Floor class using XAML? What i did is :</p> <pre><code>&lt;TextBlock Text="{Binding Path=Floors.FName }" /&gt; </code></pre> <p>but it didn't work. :(</p> <p>Sorry for the long post.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload