Browse Source

Enable WPF designer only for Window and UserControl.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3497 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
185ae7e2b0
  1. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfDisplayBinding.cs

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfDisplayBinding.cs

@ -8,7 +8,9 @@
using System; using System;
using System.IO; using System.IO;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using System.Xml;
namespace ICSharpCode.WpfDesign.AddIn namespace ICSharpCode.WpfDesign.AddIn
{ {
@ -35,7 +37,23 @@ namespace ICSharpCode.WpfDesign.AddIn
public bool CanAttachTo(IViewContent content) public bool CanAttachTo(IViewContent content)
{ {
return Path.GetExtension(content.PrimaryFileName).Equals(".xaml", StringComparison.OrdinalIgnoreCase); if (Path.GetExtension(content.PrimaryFileName).Equals(".xaml", StringComparison.OrdinalIgnoreCase)) {
IEditable editable = content as IEditable;
if (editable != null) {
try {
XmlTextReader r = new XmlTextReader(new StringReader(editable.Text));
r.XmlResolver = null;
r.WhitespaceHandling = WhitespaceHandling.None;
while (r.NodeType != XmlNodeType.Element && r.Read());
if (r.LocalName == "Window" || r.LocalName == "UserControl")
return true;
} catch (XmlException) {
return false;
}
}
}
return false;
} }
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent) public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent)

Loading…
Cancel
Save