How to use binding for IsReadOnly property of a DateTimeField? - wpf

I have XamDataGrid with couple of DateTimeFields, Now I have to bind IsReadOnly property of the column to a property of DataItem.
How can I achieve this using ValueConverters?

Related

Same ItemsSource in multiple ComboBox elements, SelectedIndex synced for all ComboBox elements, want separate

I have multiple ComboBox elements. Each ComboBox's ItemsSource is bound to the same property. That property is a ListCollectionView whose underlying list is an ObservableCollection. Each ComboBox's SelectedIndex is bound to a different property. My problem is that when the user changes one ComboBox all the others are changed to the same item.
How can I make the SelectedIndex properties independent? Do I need to use something other than ListCollectionView or ObservableCollection? Would binding to something other than SelectedIndex help?
After some poking around I found that the ComboBox property IsSynchronizedWithCurrentItem fixed my problem. When set to false my ComboBoxes became independent.

ReadOnlyCollection current item

I'm using MVVM pattern and C#, I public a ReadOnlyCollection property from View-Model,
In View, there is a TabControl that ItemsSource property is Binding to this ReadOnlyCollection Property.
How can I know which item is being selected from View-Model?
If ReadOnlyCollection cannot do this, what type should i use?
Thank you.
You can bind to the SelectedItem property of the TabControl to an additional property in your ViewModel.
Check MSDN for all the properties of TabControl.

Use SelectedItem in a WPF Treeview

How can i use the SelectedItem in a treeview? I want to bind i to my Model. Why is this property in the treeview readonly? Is there a xaml Solution without Code-behind?

Programmatically highlight combobox item

Is there any way to highlight comboboxitem programmatically?
Property IsHighlighted has no setter((. Changing style is not enought.
If you goal is to select rather than highlight (the IsHighlighted property is used to indicate a selected item), you can just set the IsSelected property or the SelectedItem or SelectedValue of the parent ComboBox.

Auto refresh ItemTemplateSelector

I have ItemsControl with multi DataTemplate and use ItemTemplateSelector to chose appropriate DataTemplate of each item of ItemsSource. I want to binding ItemTemplateSelector to TemplateType dependency property of item. and each time TemplateType property changed, DataTemplate change automaticaly. How can I do.
I Search about own question. and find below code to refresh ItemTemplateSelector :
DataTemplateSelector DataTemplateSelector = plan.ItemTemplateSelector;
plan.ItemTemplateSelector = null;
plan.ItemTemplateSelector = DataTemplateSelector;
I'd go for a different solution in your case, if you want to update the datatemplate.
I would create a binding to the ItemTemplate of your ItemsControl. That binding gets a converter assigned, which contains the logic of your current ItemTemplateSelector. And the source of the binding is your TemplateType property.
The ItemTemplateSelector is just for one-shot evaluation.

Resources