In all the examples only shows their sources, I want to set the values ​​myself. How to do it?

  • four
    - I accidentally full bottle of cola. - Are you by chance what? - A full bottle of cola. - petya

1 answer 1


<Window.Resources> <x:Array x:Key="persons" Type="{x:Type local:Person}" xmlns:local="clr-namespace:WpfApplication146"> <local:Person FirstName="Sarfaraz" LastName="Nawaz"/> <local:Person FirstName="Prof" LastName="Plum"/> </x:Array> </Window.Resources> <Grid> <DataGrid Name="MyLittleTable" ItemsSource="{Binding Source={StaticResource persons}}"/> </Grid> 

in xmlns: local, you need to replace not your namespace with yours.

Incredibly, but:

 public class Person { public string FirstName { get; set; } public string LastName { get; set; } }