我們在寫WPF控件的時候,經常會需要在xaml文件添加一些引用, 如System.Windows.Forms引用,但是在xaml文件沒有提供類似於 using System.Windows.Forms; 的語法, 因此我們需要通過 xmlns關鍵字來添加引用。具體實現如下:
xmlns:wf="clr-namespace:System.Windows.Forms; assembly=System.Windows.Forms"
其中: wf為引用別名,在xaml文件中,可以用wf來代替該引用;
clr-namespace:引用名字; assembly=引用對應的DLL名字
