本帖最后由 Invoker 于 2014-4-27 22:16 编辑
- <ListBox x:Name="Display"
- Grid.Row="1"
- Width="488"
- Height="293"
- Margin="52,30,0,0"
- HorizontalAlignment="Left"
- VerticalAlignment="Top"
- FontSize="16"
- ItemsSource="{Binding customInfo}"
- Opacity="0.5" Grid.ColumnSpan="2">
复制代码 我对一个listbox绑定一个ObservableCollection类型的数据,并且采用VIEW-MODEL形式绑定到UI上- public class customViewModel:INotifyPropertyChanged
- {
- //存取数据的数据结构
- public ObservableCollection<CustomInfo> customInfo { get; set; }
- public customViewModel()
- {
- this.customInfo = new ObservableCollection<CustomInfo>();
- }
- }
复制代码- public customViewModel Model
- {
- get { return this.DataContext as customViewModel; }
- set { this.DataContext = value; }
- }
- public MainWindow()
- {
- InitializeComponent();
- this.Model = new customViewModel();
- }
复制代码 但是还是无法通知UI界面 这个是为什么呢
|