Search code examples
uwpmaster-detailwindows-template-studio

UWP - How to implement a data entry form in "MasterDetailsView" template?


I have a nice working MasterDetails view made with the Windows Templating Studio, and I want to use the "Noselection" state to implement a data entry form.

But... I've absolutely no idea wher to strat for that...

(I know how to force displaying of NoSelection display, setting "Selected" value to null.)

Any help would be nice!

[EDIT 1]

    <DataTemplate x:Key="NoSelectionContentTemplate">
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <views:AddContrat />
            <!--TextBlock
                x:Uid="Contrats_NoSelection"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Style="{StaticResource SubtitleTextBlockStyle}"
                TextAlignment="Center" /-->
        </Grid>
    </DataTemplate>

But... has an error :

Severity Code Description Project File Line Suppression State Detail Description Error XDG0062 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Data.Sqlite.SqliteException: SQLite Error 1: 'no such table: Residences'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext() at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext() at Microsoft.Data.Sqlite.SqliteDataReader.N GestionGarages ContratsPage.xaml 38 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Data.Sqlite.SqliteException: SQLite Error 1: 'no such table: Residences'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext() at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext() at Microsoft.Data.Sqlite.SqliteDataReade

The code compiles and run with no problem...

What could be the cause of this error ?


Solution

  • UWP - How to implement a data entry form in “MasterDetailsView” template?

    MasterDetailsView has NoSelectionContentTemplate property, you could place the data entry here like the following.

    <controls:MasterDetailsView.NoSelectionContentTemplate>
                    <DataTemplate>
                        <StackPanel HorizontalAlignment="Center" 
                                    VerticalAlignment="Center">
                            <SymbolIcon Symbol="Mail" 
                                        RenderTransformOrigin=".5,.5">
                                <SymbolIcon.RenderTransform>
                                    <CompositeTransform 
                                      ScaleX="2" 
                                      ScaleY="2"/>
                                </SymbolIcon.RenderTransform>
                            </SymbolIcon>
                            <TextBlock Text="Please select item" 
                                       FontSize="24" 
                                       Margin="0,12"/>
                        </StackPanel>
                    </DataTemplate>
    </controls:MasterDetailsView.NoSelectionContentTemplate>