propertychanged

PropertyChanged event null after setting DataContext

会有一股神秘感。 提交于 2019-12-14 03:11:05
问题 I am setting the DataContext for my View in the View's Constructor to an instance of my ViewModel, just standard stuff. Shortly thereafter, an UPDATE_RECENT_DOCUMENTS_LIST Event fires from the Event Aggregator which my ViewModel catches correctly. A property is changed and the onPropertyChanged method is called, but it fails as the PropertyChanged event is null. The very next thing I do is an action to the UI which raises a CREATE_PROJECT Event and the same ViewModel is receiving events,

UpdateSourceTrigger PropertyChanged in Silverlight?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 16:39:55
问题 I am sure most of you have come across this when you type in a textbox you like instantly to filter a ViewCollection according to has been typed. Its very straight forward in WPF, just change the UpdateSourceTrigger for Text binding to PropertyChanged. As you would expect Silverlight doesnt have it. There is just a default and explicit instead. I had the idea to bind an Interaction behavior to TextChanged event of the textbox instead. Would you recommend this approach or is there a better way

C# Wpf Editing Datagrid does not update it's itemsource

て烟熏妆下的殇ゞ 提交于 2019-12-06 04:19:55
问题 I have an ObservableCollection like this, ObservableCollection<Item> Found_Items = new ObservableCollection<Item>(); public struct Item { public bool Enabled { get; set; } public BitmapImage ItemIcon { get; set; } public string Path { get; set; } public string Size { get; set; } } I'm setting Datagrid's itemsource like this, FoundItemsDatagrid.ItemsSource = Found_Items; I have a checkbox in Datagrid like this, <DataGridTemplateColumn Header="Path" Width="*" > <DataGridTemplateColumn

ObservableCollection PropertyChanged event

怎甘沉沦 提交于 2019-12-04 21:47:03
问题 OK so I want to subclass ObservableCollection to add a property to it. Unfortunately the PropertyChanged event is protected. Basically I want to subclass it to have a SelectedItem that I can bind to for lists in my MVVM WPF app. Here's the skeleton of my class: public class SelectableList<T> : ObservableCollection<T> { public T SelectedItem {get;set;} } But I cannot do the following: SelectableList<int> intList = new SelectableList<int>(); intList.PropertyChanged += new

C# Wpf Editing Datagrid does not update it's itemsource

心已入冬 提交于 2019-12-04 11:30:18
I have an ObservableCollection like this, ObservableCollection<Item> Found_Items = new ObservableCollection<Item>(); public struct Item { public bool Enabled { get; set; } public BitmapImage ItemIcon { get; set; } public string Path { get; set; } public string Size { get; set; } } I'm setting Datagrid's itemsource like this, FoundItemsDatagrid.ItemsSource = Found_Items; I have a checkbox in Datagrid like this, <DataGridTemplateColumn Header="Path" Width="*" > <DataGridTemplateColumn.CellTemplate> <DataTemplate> <DockPanel> <CheckBox IsChecked="{Binding Path=Enabled, Mode=TwoWay,

Why can't I invoke PropertyChanged event from an Extension Method?

蓝咒 提交于 2019-12-03 23:45:03
问题 I've tried to code a class to avoid a method like "RaisePropertyChanged". I know that I can inherit from a class that has that implementation but in some cases I can't. I've tried with a Extension Method but Visual Studio complain. public static class Extension { public static void RaisePropertyChanged(this INotifyPropertyChanged predicate, string propertyName) { if (predicate.PropertyChanged != null) { predicate.PropertyChanged(propertyName, new PropertyChangedEventArgs(propertyName)); } } }

ObservableCollection PropertyChanged event

给你一囗甜甜゛ 提交于 2019-12-03 13:10:50
OK so I want to subclass ObservableCollection to add a property to it. Unfortunately the PropertyChanged event is protected. Basically I want to subclass it to have a SelectedItem that I can bind to for lists in my MVVM WPF app. Here's the skeleton of my class: public class SelectableList<T> : ObservableCollection<T> { public T SelectedItem {get;set;} } But I cannot do the following: SelectableList<int> intList = new SelectableList<int>(); intList.PropertyChanged += new PropertyChangedEventHandler(intList_Changed); because of access restrictions. This causes me to ask a deeper question. How

MVVM - binding to aggregated property

风格不统一 提交于 2019-12-02 07:57:29
问题 I have following viewmodels: public class ViewModel: INotifyPropertyChanged { public ObservableCollection<Item> Items { get; set; } ... } public class Item: INotifyPropertyChanged { public SubItem A { get; set; } public SubItem B { get; set; } ... } public class SubItem: INotifyPropertyChanged { public bool Valid { get; set; } ... } xaml: <ListBox ItemsSource="{Binding Items}" ..> If I want to display text "Valid item" if both A.Valid and B.Valid are true , then: I can do this by having logic

MVVM - binding to aggregated property

假装没事ソ 提交于 2019-12-02 07:06:43
I have following viewmodels: public class ViewModel: INotifyPropertyChanged { public ObservableCollection<Item> Items { get; set; } ... } public class Item: INotifyPropertyChanged { public SubItem A { get; set; } public SubItem B { get; set; } ... } public class SubItem: INotifyPropertyChanged { public bool Valid { get; set; } ... } xaml: <ListBox ItemsSource="{Binding Items}" ..> If I want to display text "Valid item" if both A.Valid and B.Valid are true , then: I can do this by having logic in the view (item data template), e.g using visibility and extra container: <Grid Visibility="{Binding

How to use PropertyChangedCallBack

。_饼干妹妹 提交于 2019-12-01 14:59:21
I have a TextBox Binded to a dependancy property, I have implemented a PropertyChangedCallBack function, when the text changes I need to call textbox.ScrollToEnd() but I cant since the PropertChanged function need to be static, is there a way around this? static FrameworkPropertyMetadata propertyMetaData = new FrameworkPropertyMetadata("MyWindow", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(TextProperty_PropertyChanged)); public static readonly DependencyProperty TextProperty = DependencyProperty.Register("TextProperty", typeof(string), typeof(OutputPanel