Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems Binding ViewModel to Listview
    primarykey
    data
    text
    <p>my view model</p> <pre><code>public class ExchangeViewModel : ViewModelBase { ObservableCollection&lt;string&gt; _repo = new ObservableCollection&lt;string&gt;() { "CME", "CFE", "LIFFE" }; #region Properties public ObservableCollection&lt;string&gt; Exchanges { get { return _repo; } } #endregion // Properties #region Constructors public ExchangeViewModel() { } #endregion // Constructors } </code></pre> <p>my view </p> <pre><code>&lt;Window x:Class="ListviewTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"&gt; &lt;Grid&gt; &lt;ListView Grid.Row="0" Grid.Column="0" SelectionMode="Single" DataContext="{Binding}" &gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridViewColumn DisplayMemberBinding="{Binding Exchanges}" Header = "Exchange" &gt; &lt;/GridViewColumn&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;/ListView&gt; &lt;/Grid&gt; </code></pre> <p></p> <p>and i bind them together in app.xaml.cs</p> <pre><code>public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); MainWindow window = new MainWindow(); // Create the ViewModel to which // the main window binds. //string path = "Data/customers.xml"; ExchangeViewModel viewModel = new ExchangeViewModel(); // Allow all controls in the window to // bind to the ViewModel by setting the // DataContext, which propagates down // the element tree. window.DataContext = viewModel; window.Show(); } } </code></pre> <p>but when i run the application my listview is empty. my binded exchanges property doesn't even get call which is a sign that my binding is not done properly.</p>
    singulars
    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.
 

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