Hi,
I have created new GridViewDateTimeColumn that will handle DateTime properties. In this column I have added one dependency property that will define StringFormat for DateTime values.
xaml
However, since the cell/column layout is created only once, I am unable to force the Column to rebind its values. StringFormatChanged is executed, and StringFormat property for column DataMemberBinding is set correctly, but original StringFormat is still active.
How can I make this work?
Regards,
Goran
I have created new GridViewDateTimeColumn that will handle DateTime properties. In this column I have added one dependency property that will define StringFormat for DateTime values.
// Dependency Propertypublic static readonly DependencyProperty StringFormatProperty = DependencyProperty.Register("StringFormat", typeof(string), typeof(GridViewDateTimeColumn), new FrameworkPropertyMetadata(string.Empty, StringFormatChanged));public string StringFormat{ get { return (string)GetValue(StringFormatProperty); } set { SetValue(StringFormatProperty, value); }}private static void StringFormatChanged(DependencyObject d, DependencyPropertyChangedEventArgs e){ var column = (GridViewDateTimeColumn)d; column.DataMemberBinding.StringFormat = e.NewValue.ToString(); column.Refresh();}xaml
<my_controls:GridViewDateTimeColumn DataMemberBinding="{Binding SomeDateTimeProperty, Mode=TwoWay}" StringFormat="{Binding DataContext.StringFormat, RelativeSource={RelativeSource AncestorType=UserControl}}" >However, since the cell/column layout is created only once, I am unable to force the Column to rebind its values. StringFormatChanged is executed, and StringFormat property for column DataMemberBinding is set correctly, but original StringFormat is still active.
How can I make this work?
Regards,
Goran