combine competitionlist with combobox

This commit is contained in:
Natlinux
2022-11-07 20:59:15 +01:00
parent 149e6caa9a
commit cc6636528c
7 changed files with 132 additions and 16 deletions

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Nullable>disable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apollon.Domain.Models
{
public class Competition
{
public string CompetitionName{ get; set; }
public string CompetitionImage{ get; set; }
}
}

View File

@@ -0,0 +1,64 @@
// <auto-generated />
using System;
using Apollon.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Apollon.EntityFramework.Migrations
{
[DbContext(typeof(TournamentsDbContext))]
[Migration("20221107194347_competition")]
partial class competition
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.8")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("Apollon.EntityFramework.DTOs.TournamentDto", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("Competition")
.HasColumnType("nvarchar(max)");
b.Property<string>("CompetitionImage")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("EndDate")
.HasColumnType("datetime2");
b.Property<string>("Location")
.HasColumnType("nvarchar(max)");
b.Property<string>("Organisation")
.HasColumnType("nvarchar(max)");
b.Property<int>("Rounds")
.HasColumnType("int");
b.Property<DateTime>("StartDate")
.HasColumnType("datetime2");
b.Property<string>("TournamentName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Tournaments");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,19 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Apollon.EntityFramework.Migrations
{
public partial class competition : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Apollon.WPF"
xmlns:components="clr-namespace:Apollon.WPF.Views.Components"
xmlns:views="clr-namespace:Apollon.WPF.Views"
xmlns:vms="clr-namespace:Apollon.WPF.ViewModels"
xmlns:custom="clr-namespace:ModalControl;assembly=ModalControl"
@@ -30,6 +31,9 @@
<DataTemplate DataType="{x:Type vms:OverviewViewModel}">
<views:OverviewView Content="{Binding CurrentViewModel}" DataContext="{Binding OverviewViewModel}"/>
</DataTemplate>
<DataTemplate DataType="{x:Type vms:AddEditDetailsViewModel}">
<components:AddEditDetails/>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Apollon.Domain.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -166,19 +167,38 @@ namespace Apollon.WPF.ViewModels
public ICommand SubmitCommand { get; }
public ICommand CancelCommand { get; }
public ObservableCollection<string> CompetitionList { get; set; }
public ObservableCollection<Competition> CompetitionList { get; set; }
public AddEditDetailsViewModel(ICommand submitCommand, ICommand cancelCommand)
{
SubmitCommand = submitCommand;
CancelCommand = cancelCommand;
CompetitionList = new ObservableCollection<string>
CompetitionList = new ObservableCollection<Competition>
{
"Halle", "im Freien", "Feld", "3D"
};
new Competition
{
CompetitionName = "Halle",
CompetitionImage = "targetHall.png"
},
new Competition
{
CompetitionName = "im Freien",
CompetitionImage ="targetOutdoor.png"
},
new Competition
{
CompetitionName = "Feld",
CompetitionImage = "targetField.png"
},
Competition = CompetitionList[1];
new Competition
{
CompetitionName = "3D",
CompetitionImage = "3d.png"
}
};
}
}

View File

@@ -71,7 +71,6 @@
Background="LightGray"/>
<ComboBox Grid.Row="2"
x:Name="ComboBox"
Text="{Binding Competition}"
IsReadOnly="False"
IsEditable="True"
@@ -81,12 +80,8 @@
FontSize="16"
VerticalContentAlignment="Center"
HorizontalAlignment="Left"
ItemsSource="{Binding CompetitionList}">
<!--<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Source=}"/>
</DataTemplate>
</ComboBox.ItemTemplate>-->
ItemsSource="{Binding CompetitionList}"
DisplayMemberPath="CompetitionName">
</ComboBox>
<Image x:Name="CompetitionImage"