我正在嘗試編寫一個通用控件,在其中我可以INotifyPropertyChanged使用轉換器傳遞不同的數據模型(全部實現)。數據在控件中傳遞沒有問題,并且顯示正確(其中一些還使用IMultivalueConverts,它工作完美)。雖然修改了數據,但是IMultiValueConverter并沒有調用MainControl的。通用控件應該只顯示根據 ObservableCollection 中的坐標計算出的矩形。我將 DebugConverters 放在所有綁定上,除了頂部的 ConvertBack 之外,所有內容似乎都已更新。還調用 ListBox 中的 SourceUpdate。我用不同的 NotifyOn...Updated、Mode 和 UpdateSourceTrigger 嘗試了這個轉換器,我總是看到控件中的值發生變化,但從未看到主控件的 ConvertBack。使用的部分數據模板(更新正確完成),所有 DegreeTo... 轉換器都以兩種方式調用 <DataTemplate x:Key="RectangleWithLabel"> <Canvas IsHitTestVisible="True"> <Rectangle x:Name="RectangleROI" MouseLeftButtonDown="myCanvas_PreviewMouseLeftButtonDown" > <!-- <Rectangle.Visibility> <Binding Path="ROI" Converter="{StaticResource NullToVisibilityConverter}"/> </Rectangle.Visibility> --> <Canvas.Left> <MultiBinding Converter="{StaticResource DegreeToScreenPixelConverterH}" Mode="TwoWay" NotifyOnSourceUpdated="True" NotifyOnTargetUpdated="True" UpdateSourceTrigger="PropertyChanged" > <Binding Path="ROI.Begin.PosH" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" NotifyOnSourceUpdated="True" NotifyOnTargetUpdated="True" /> <Binding Path="DataContext.UsedCoordinateSystem" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type UserControl}}" NotifyOnSourceUpdated="True" Mode="TwoWay" NotifyOnTargetUpdated="True" UpdateSourceTrigger="PropertyChanged" /> </MultiBinding> </Canvas.Left> <Canvas.Top>
未調用 ConvertBack
慕碼人2483693
2023-09-09 17:13:49