nv3
nv3

Reputation: 396

How does the VS editor know about controls in the XAML part

It almost seems like magic that as soon as I enter a control with a Name="myControl" attribute to the XAML code of a window, the editor of Visual Studio knows about the corresponding member variable in the code-behind. So the editor and intellisense seem to scan the XAML code at design time in order to anticipate which member variables the framework will create at runtime for the controls of a window. What exactly goes on behind the scenes for this to work? My guess is that VS uses the System.Windows.Markup.IComponentConnector interface at design time to find out about the properties of a window class.

Upvotes: 1

Views: 35

Answers (1)

Sinatr
Sinatr

Reputation: 21999

When you are working with window/user control xaml in designer you are changing both: xaml and designer generated cs (look inside obj folder, there are WindowName.g.cs and WindowName.g.i.cs).

As soon as you add x:Name it will appears as a property in designer generated cs. Then you (or Intellisense) is able to use it when you are editing xaml.cs.

Upvotes: 2

Related Questions