2

начинаю изучать WPF, возникли вопросы:

  • где посмотреть все доступные ЗАШИТЫЕ пространства имён которые можно использовать в XAML?
  • где посмотреть конкретно какие пространства имён .Net отображаются на каждом зашитом пространстве имён XAML?

Спасибо!

3

1 ответ 1

4

Вопрос не совсем корректен, но я попытаюсь ответить. Итак, никакие пространства имен в XAML не "зашиты", можно объявлять и использовать любые пространства имен, например:

xmlns:c="clr-namespace:WpfTest"

НО, для удобства, можно назначить один алиас для группы пространств имен и, после объявления этого алиаса в XAML, использовать всё что в нем лежит, так сделано со штатными пространствами имен из BCL, например:

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

Делается это с помощью атрибута XmlnsDefinition, который используется на уровне сборки (например, в Properties/AssemblyInfo.cs)

Если вы хотите узнать, что скрывается под штатными алиасами (под тем же http://schemas.microsoft.com/winfx/2006/xaml/presentation) или под алиасами, которые добавляет какая-нибудь библиотека, необходимо смотреть исходники.

Пример в PresentationFramework: https://referencesource.microsoft.com/#PresentationFramework/src/Framework/OtherAssemblyAttrs.cs

// Namespace information for Xaml
[assembly:System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Controls")]
[assembly:System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Documents")]
[assembly:System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Shapes")]
[assembly:System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Shell")]
[assembly:System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Navigation")]
[assembly:System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Data")]
[assembly:System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows")]
[assembly:System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Controls.Primitives")]
[assembly:System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Media.Animation")]
[assembly:System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Input")]
[assembly: System.Windows.Markup.XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Media")]

Т.е. под http://schemas.microsoft.com/winfx/2006/xaml/presentation скрываются пространства имен:

System.Windows.Controls
System.Windows.Documents
System.Windows.Shapes
System.Windows.Shell
System.Windows.Navigation
System.Windows.Data
System.Windows
System.Windows.Controls.Primitives
System.Windows.Media.Animation
System.Windows.Input
System.Windows.Media
0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.