Pushing read-only GUI properties back into ViewModel

后端 未结 6 1882
攒了一身酷
攒了一身酷 2020-11-22 12:50

I want to write a ViewModel that always knows the current state of some read-only dependency properties from the View.

Specifically, my GUI contains a FlowDocumentPa

6条回答
  •  一向
    一向 (楼主)
    2020-11-22 13:28

    I like Dmitry Tashkinov's solution! However it crashed my VS in design mode. That's why I added a line to OnSourceChanged method:

        private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (!((bool)DesignerProperties.IsInDesignModeProperty.GetMetadata(typeof(DependencyObject)).DefaultValue))
                ((DataPipe)d).OnSourceChanged(e);
        }
    

提交回复
热议问题