I have a simple window:
<Window x:Class="WinActivityManager" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Grid> <ListView x:Name="lvItems" /> </Grid> </Window>
And the related code behind:
public partial class WinActivityManager : Window { private ObservableCollection<Activity> Activities { get; set; } public WinActivityManager() { Activities = new ObservableCollection<Activity>(); InitializeComponent(); }
If I write the following binding in the window constructor:
lvItems.ItemsSource = Activities;
then my ListView is automatically updated when I add or remove items from Activities .
How to write binding in XAML?
I tried this, but it does not work:
<ListView x:Name="lvItems" ItemsSource="{Binding=Activities}" />
How to do this in XAML?
Jonny piazzi
source share