Following shows part of my MainWindow.xaml:
<Grid>
<ListBox x:Name="listBox" (Line #40)
ItemsSource="{Binding Rectangles}"
SelectionMode="Extended" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style
TargetType="{x:Type ListBoxItem}" >
<Setter
Property="Canvas.Left"
Value="{Binding X}" />
<Setter
Property="Canvas.Top"
Value="{Binding Y}" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<Canvas x:Name="dragSelectionCanvas" (Line #64)
Visibility="Collapsed" >
<Border x:Name="dragSelectionBorder" (Line #66)
Opacity="0.5" />
</Canvas>
</Grid>
And this is the corresponding MainWindow.g.i.cs file generated by Visual Studio:
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {
#line 40 "..\..\MainWindow.xaml"
internal System.Windows.Controls.ListBox listBox;
#line 64 "..\..\MainWindow.xaml"
internal System.Windows.Controls.Canvas dragSelectionCanvas;
#line 66 "..\..\MainWindow.xaml"
internal System.Windows.Controls.Border dragSelectionBorder;
(I have deleted some lines for sake of brevity.)
I can see in the .cs file that for every XAML element with an x:Name
attribute, Visual Studio generates a corresponding member declaration.
My question: Where are the declarations for those XAML elements, such as the Grid
element above as well as the outer Window
element (not shown) that do not have an x:Name
attribute? Are they declared as well behind the scenes?