04.04.2022
This commit is contained in:
parent
5190f4d046
commit
77ec2ab7e6
8
Test_App/Ressources/Students.json
Normal file
8
Test_App/Ressources/Students.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
[
|
||||
{
|
||||
"ID": "1",
|
||||
"Question": "John Doe",
|
||||
"Answer": "Male"
|
||||
|
||||
}
|
||||
]
|
|
@ -138,6 +138,7 @@
|
|||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Ressources\Students.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
|
|
|
@ -6,16 +6,15 @@
|
|||
xmlns:local="clr-namespace:Test_App.Views"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="525" d:DesignWidth="602">
|
||||
|
||||
|
||||
<Page.Resources>
|
||||
<DataTemplate x:Key="datas">
|
||||
<Border Name="border" BorderBrush="DarkSlateBlue" BorderThickness="2"
|
||||
CornerRadius="2" Padding="5" Margin="5" Background="WhiteSmoke">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
|
@ -25,16 +24,23 @@
|
|||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Padding="0,0,5,0" Text="ID:"/>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Path=ID}"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Padding="0,0,5,0" Text="Name:"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Path=Name}"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Padding="0,0,5,0" Text="Gender:"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Path=Gender}"/>
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Padding="0,0,5,0" Text="Class:"/>
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding Path=Class}"/>
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" Padding="0,0,5,0" Text="Seat:"/>
|
||||
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding Path=Seat}"/>
|
||||
<TextBlock Grid.Row="5" Grid.Column="0" Padding="0,0,5,0" Text="Comment:"/>
|
||||
<TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding Path=Comment}"/>
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Padding="0,0,5,0" Text="Question: "/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Path=Question}"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Padding="0,0,5,0" Text="Answer:"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Path=Answer}"/>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
|
||||
<DockPanel>
|
||||
<Label DockPanel.Dock="Top" FontSize="20" Margin="5" Content="Database"/>
|
||||
<ListBox x:Name="datalist"
|
||||
ItemsSource="{Binding}"
|
||||
ItemTemplate="{StaticResource datas}"
|
||||
HorizontalAlignment="Stretch"
|
||||
IsSynchronizedWithCurrentItem="True"
|
||||
Margin="5,0,5,5" />
|
||||
</DockPanel>
|
||||
</Page>
|
||||
|
|
|
@ -25,8 +25,29 @@ namespace Test_App.Views
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
OutputJson();
|
||||
|
||||
}
|
||||
public void OutputJson()
|
||||
|
||||
{
|
||||
string json = "";
|
||||
var webclient = new System.Net.WebClient();
|
||||
webclient.Encoding = Encoding.UTF8;
|
||||
try
|
||||
{
|
||||
json = webclient.DownloadString("https://git.weifer.org/weifer/Pruefungskatalog/raw/branch/master/assets/questions_answers.json");
|
||||
}
|
||||
catch (System.Net.WebException e)
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
datalist.ItemsSource = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Ressources.Datas>>(json);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Newtonsoft.Json;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
Loading…
Reference in New Issue
Block a user