1

Markup.XamlReader.Load メソッドでカスタム名前空間を持つ .xaml ファイルを開くことができません。私はこれが好きです:

stream = openFileDialog1.OpenFile();
System.Windows.Markup.ParserContext parserContext = new System.Windows.Markup.ParserContext();
parserContext.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
parserContext.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
parserContext.XmlnsDictionary.Add("ex", "clr-namespace=Extensions;assembly=Extensions");

viewport = System.Windows.Markup.XamlReader.Load(stream, parserContext) as Viewport3D;  

アセンブリに次の DependencyProperty があります。

namespace Extensions
{
    public class Ext
    {
        public static DependencyProperty NameProperty = DependencyProperty.RegisterAttached("Name", typeof(string), typeof(Ext));

        public static string GetName(DependencyObject target)
        {
            return (string)target.GetValue(NameProperty);
        }

        public static void SetName(DependencyObject target, string name)
        {
            target.SetValue(NameProperty, name);
        }
    }
}

私の問題は、XamlReader.Load メソッドで XamlParseException を取得して、次のことを伝えていることです。不明なメンバー {clr-namespace=Extensions;assembly=Extensions}Name を設定できません。

.xaml ファイルの「不明なメンバー」は、次のように ModelVisual3D オブジェクトに設定されます。

このエラーについて私が見つけたすべてのことは、私がすでに試したことを実行することを示唆しています。私を助けてください!

4

1 に答える 1