= Example WPF project using C# .NET Core 6.0 =

== Getting Started ==

This is just the start of the project. Much of the work can be seen on [[https://github.com/scotpatti/BibleBeliefs|github]].

 * Create a .NET Core WPF application
 * Create a folder in the project called "Database"
 * Add the [[attachment:BibleBeliefs.db|BibleBeliefs.DB]] file to the new "Database" folder. 
 * Set the file to be copied to the output folder if newer.

Add the following nuget packages:

 * Microsoft.!EntityFrameworkCore
 * Microsoft.!EntityFrameworkCore.Sqlite
 * Microsoft.!EntityFrameworkCore.Tools

{{{
PM> Scaffold-DbContext "DataSource=.\DataBase\BibleBeliefs.db;" Microsoft.EntityFrameworkCore.SQLite -OutputDir "Database" -ContextDir "Database"
}}}

== Add a Data Context to the xaml ==

Add a namespace for the !ViewModels directory

{{{#!highlight xml
xmlns:viewmodels="clr-namespace:BibleBeliefs.ViewModels"
}}}

Add the Data Context

{{{#!highlight xml
<Window.DataContext>
     <viewmodels:MainViewModel/>
</Window.DataContext>
}}}

== Adding Data to the application ==

Now add the Grid

{{{#!highlight xml
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="250" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition />
        </Grid.RowDefinitions>
        <DataGrid Grid.Row="0" Grid.Column="0" 
                  ItemsSource="{Binding Topics}" 
                  AutoGenerateColumns="False" 
                  SelectedItem="{Binding SelectedTopic}">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Topic" Binding="{Binding Topic}"  Width="*"/>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
}}}