1
我有一個OxyPlot視圖的WPF窗口。我正在嘗試添加每個系列的隱藏/顯示功能,基於該圖的動態生成的可檢查上下文菜單。 這個想法是有一個ObservableCollection<T>
對象,綁定到上下文菜單的ItemsSource
,其中T是一個基本上包含系列標題作爲字符串和默認檢查狀態爲布爾值的類。 View.xaml的WPF和OxyPlot:Checkable ContextMenu,動態生成
摘錄:
<oxy:PlotView
x:Name="oxyPlot"
Model="{Binding PlansPlotModel}"
Controller="{Binding PlansPlotController}">
<oxy:PlotView.ContextMenu>
<ContextMenu ItemsSource="{Binding PlansPlotContextMenuItems}">
<ContextMenu.ItemTemplate>
<DataTemplate>
<MenuItem Header="{Binding Title}"
IsCheckable="True"
IsChecked="{Binding IsCheckedByDefault}" />
</DataTemplate>
</ContextMenu.ItemTemplate>
</ContextMenu>
</oxy:PlotView.ContextMenu>
</oxy:PlotView>
上下文菜單顯示正常,但複選框是在錯誤的地方,它有鼠標懸停一個奇怪的現象:
預期結果:
實際結果:
我缺少什麼?
TIA