1.

Write A Program That Adds Two Columns Binded With The Same Properties And Having Column Headings Using Xaml?

Answer»
  • Columns can be added in their own way by making two different columns and adding them using the function of Column.Add().
  • The order of the columns is not determined by the order in which they are shown or stored. To list the order use of DisplayIndex PROPERTY is used. 
  • To add the columns that are binded with one another FIRST there is a need to create the data and add the data to the items collection. 
  • XAML is used to instantiate and initialize the two columns and produces the same result with the in-built function as normal language. 

<DataGrid Height="50
HorizontalAlignment="Right" 
MARGIN="7,9,0,0" 
Name="dataGrid" 
VerticalAlignment="Top" 
Width="100" >
<DataGrid.Columns>
<DataGridTextColumn 
Binding="{Binding Path=name}" 
Header="Name">
</DataGridTextColumn>
<DataGridTextColumn 
Binding="{Binding Path=age}
Header="Age">
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>

<DataGrid Height="50" 
HorizontalAlignment="Right" 
Margin="7,9,0,0" 
Name="dataGrid" 
VerticalAlignment="Top" 
Width="100" >
<DataGrid.Columns>
<DataGridTextColumn 
Binding="{Binding Path=name}" 
Header="Name">
</DataGridTextColumn>
<DataGridTextColumn 
Binding="{Binding Path=age}
Header="Age">
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>



Discussion

No Comment Found