In all the examples only shows their sources, I want to set the values myself. How to do it?
1 answer
<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; } }
|