是否可以通過使用某些過濾來阻止將一個可錨定元素對接到另一個元素?例如,在viewmodel我可以包含一些屬性doctype
。對於一個可錨定元素,doctype
的值將爲「a」,另一個爲「b」。我如何使用屬性doctype
來防止停靠,如果錨定元素的值「a」無法與doctype
「b」對接錨定元素?也許,還有其他解決方案。防止對接AvalonDock
1
A
回答
0
我在LayoutAnchorableFloatingWindowControl.cs
改變IOverlayWindowHost.GetDropAreas
方法
第一步是intializing的內容的類型。
var floatingWindowContentHost = Content as FloatingWindowContentHost;
if (floatingWindowContentHost == null) return _dropAreas;
var rootVisual = floatingWindowContentHost.RootVisual;
Type type = null;
var layoutAnchorableFloatingWindow = draggingWindow.Model as LayoutAnchorableFloatingWindow;
if (layoutAnchorableFloatingWindow != null)
{
//big part of code for getting type
var layoutAnchorablePane = layoutAnchorableFloatingWindow.SinglePane as LayoutAnchorablePane;
if (layoutAnchorablePane != null
&& (layoutAnchorableFloatingWindow.IsSinglePane
&& layoutAnchorablePane.SelectedContent != null))
{
var layoutAnchorable = ((LayoutAnchorablePane)layoutAnchorableFloatingWindow.SinglePane).SelectedContent as LayoutAnchorable;
if (layoutAnchorable != null)
type = layoutAnchorable.Content;
}
else
{
var pane = GetLayoutAnchorablePane(layoutAnchorableFloatingWindow.RootPanel);
if (pane == null || pane.SelectedContent == null)
return null;
var layoutAnchorable = pane.SelectedContent as LayoutAnchorable;
if (layoutAnchorable != null)
type = layoutAnchorable.Content;
}
}
此後,我只是比較兩種類型,並把需要到_dropAreas
。
foreach (var areaHost in rootVisual.FindVisualChildren<LayoutAnchorablePaneControl>())
{
Type areahostType = null;
var layoutAnchorablePane = areaHost.Model as LayoutAnchorablePane;
if (layoutAnchorablePane != null && layoutAnchorablePane.SelectedContent != null)
{
var layoutAnchorable = ((LayoutAnchorablePane)areaHost.Model).SelectedContent as LayoutAnchorable;
if (layoutAnchorable != null)
areahostType = layoutAnchorable.Content;
}
// prevent docking different documents
if (type != null && areahostType != null && areahostType == type)
{
_dropAreas.Add(new DropArea<LayoutAnchorablePaneControl>(areaHost, DropAreaType.AnchorablePane));
}
}
爲了防止對接成文檔區域,需要在DockingManager.cs
對於視覺防止DropTargets來做出同樣的方法改變需要改變OverlayWindow.cs
0
這是正確的更改IOverlayWindowHost.GetDropAreas
,但這一改變對我來說似乎更容易。
我簡單的 「LayoutAnchorableFloatingWindowControl.cs」 刪除此的foreach:
...
// Remove this foreach
foreach (var areaHost in rootVisual.FindVisualChildren<LayoutDocumentPaneControl>())
{
_dropAreas.Add(new DropArea<LayoutDocumentPaneControl>(
areaHost,
DropAreaType.DocumentPane));
}
return _dropAreas;
,並在 「DockingManager.cs」 其他實施必須添加一個其他的原因:
if (!isDraggingDocuments)
{
_areas.Add(new DropArea<DockingManager>(
this,
DropAreaType.DockingManager));
foreach (var areaHost in this.FindVisualChildren<LayoutAnchorablePaneControl>())
{
if (areaHost.Model.Descendents().Any())
{
_areas.Add(new DropArea<LayoutAnchorablePaneControl>(
areaHost,
DropAreaType.AnchorablePane));
}
}
}
// -----> This else is new
else
{
foreach (var areaHost in this.FindVisualChildren<LayoutDocumentPaneControl>())
{
_areas.Add(new DropArea<LayoutDocumentPaneControl>(
areaHost,
DropAreaType.DocumentPane));
}
foreach (var areaHost in this.FindVisualChildren<LayoutDocumentPaneGroupControl>())
{
var documentGroupModel = areaHost.Model as LayoutDocumentPaneGroup;
if (documentGroupModel.Children.Where(c => c.IsVisible).Count() == 0)
{
_areas.Add(new DropArea<LayoutDocumentPaneGroupControl>(
areaHost,
DropAreaType.DocumentPaneGroup));
}
}
}
return _areas;
所以,如果您不拖動LayoutDocument,則不要將文檔窗格控件添加到拖放區域。
這就是它 - 適用於我。
相關問題
- 1. avalonDock在對接時卸載內容
- 2. 防止拼接
- 3. 防止SKLabelNode接收Touches
- 4. 防止間接通信
- 5. 防止頁面鏈接
- 6. 防止直接訪問PHP
- 7. 防止連接關閉JSoup
- 8. 如何防止Qt鏈接
- 9. 如何防止git接收
- 10. 防止ffmpeg接管stdout
- 11. avalondock mvvm
- 12. 防止在對方接受請求之前寫入套接字
- 13. iOS - 防止對象釋放
- 14. 防止對話形式
- 15. 防止對話建立
- 16. 防止EditText自動對焦
- 17. 防止對象切片 - C++
- 18. 防止對象縮放
- 19. 防止多個對象
- 20. .htaccess防止ajax請求的直接訪問防止技術
- 21. 防止直接鏈接到.zip文件
- 22. 防止接受非本地連接
- 23. 如何防止鏈接超鏈接
- 24. Restyling AvalonDock高對比度主題?
- 25. 使用Xceed AvalonDock
- 26. Avalondock MVVM佈局
- 27. 司令部AvalonDock
- 28. WPF AvalonDock ExpressionDark
- 29. AutoHideWidth爲AvalonDock
- 30. 如果不需要,防止對象被鏈接?
對接系統如果不能對接,應該如何反應? – dymanoid
感謝您的提問。我想,應該檢查'doctype'在可拖動或停靠事件。我不知道這是如何在AvalonDock工作。 –