datagrid 编辑双向绑定生效还要加下面这句,否则无效,一点都不好用
UpdateSourceTrigger=PropertyChanged
brush赋值颜色:
dayBoxCtrl.DayAppointmentsStack.Background = new SolidColorBrush(Color.FromArgb(100, 250, 230, 160));
在后台new了个Item后没有绑定就可能会报错:System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='System.Windows.Controls.ItemsControl', AncestorLevel='1''. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')
类似这样的,莫名其妙。所以如果不用在界面中的元素,不要随便创建wpf对象