我正在嘗試編寫一個(gè)通用控件,在其中我可以INotifyPropertyChanged使用轉(zhuǎn)換器傳遞不同的數(shù)據(jù)模型(全部實(shí)現(xiàn))。數(shù)據(jù)在控件中傳遞沒有問題,并且顯示正確(其中一些還使用IMultivalueConverts,它工作完美)。雖然修改了數(shù)據(jù),但是IMultiValueConverter并沒有調(diào)用MainControl的。通用控件應(yīng)該只顯示根據(jù) ObservableCollection 中的坐標(biāo)計(jì)算出的矩形。我將 DebugConverters 放在所有綁定上,除了頂部的 ConvertBack 之外,所有內(nèi)容似乎都已更新。還調(diào)用 ListBox 中的 SourceUpdate。我用不同的 NotifyOn...Updated、Mode 和 UpdateSourceTrigger 嘗試了這個(gè)轉(zhuǎn)換器,我總是看到控件中的值發(fā)生變化,但從未看到主控件的 ConvertBack。使用的部分?jǐn)?shù)據(jù)模板(更新正確完成),所有 DegreeTo... 轉(zhuǎn)換器都以兩種方式調(diào)用 <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>
未調(diào)用 ConvertBack
慕碼人2483693
2023-09-09 17:13:49