update combobox

This commit is contained in:
Natlinux
2022-11-07 16:09:05 +01:00
parent a18158806c
commit 149e6caa9a
3 changed files with 47 additions and 61 deletions

View File

@@ -1,5 +1,7 @@
using System;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -10,6 +12,7 @@ namespace Apollon.WPF.ViewModels
{
public class AddEditDetailsViewModel : ViewModelBase
{
private string _organisation;
public string Organisation
{
@@ -37,10 +40,10 @@ namespace Apollon.WPF.ViewModels
OnPropertyChanged(nameof(TournamentName));
OnPropertyChanged(nameof(CanSubmit));
}
}
}
private string _competition;
public string Competition
private string _competition;
public string Competition
{
get
{
@@ -49,11 +52,12 @@ namespace Apollon.WPF.ViewModels
set
{
_competition = value;
OnPropertyChanged(nameof(Competition));
OnPropertyChanged(nameof(Competition));
}
}
}
private string _competitionImage;
private string _competitionImage;
public string CompetitionImage
{
get
@@ -162,11 +166,20 @@ namespace Apollon.WPF.ViewModels
public ICommand SubmitCommand { get; }
public ICommand CancelCommand { get; }
public ObservableCollection<string> CompetitionList { get; set; }
public AddEditDetailsViewModel(ICommand submitCommand, ICommand cancelCommand)
{
SubmitCommand = submitCommand;
CancelCommand = cancelCommand;
{
SubmitCommand = submitCommand;
CancelCommand = cancelCommand;
CompetitionList = new ObservableCollection<string>
{
"Halle", "im Freien", "Feld", "3D"
};
Competition = CompetitionList[1];
}
}
}
}

View File

@@ -1,13 +1,14 @@
<UserControl x:Class="Apollon.WPF.Views.Components.AddEditDetails"
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Apollon.WPF.Views.Components"
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
xmlns:ViewModels="clr-namespace:Apollon.WPF.ViewModels" x:Class="Apollon.WPF.Views.Components.AddEditDetails"
mc:Ignorable="d">
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
@@ -27,27 +28,27 @@
<TextBlock Text="Veranstalter: "
Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="1"
Text="Turniername: "
Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="2"
Text="Wettkampfart: "
Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="3"
Text="Startdatum: "
Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="4"
Text="Enddatum: "
Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="5"
Text="Veranstaltungsort: "
Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="6"
Text="Durchgänge: "
Style="{StaticResource ModalTextBlock}"/>
@@ -59,7 +60,7 @@
Height="30"
Background="LightGray"
VerticalContentAlignment="Center"/>
<TextBox Grid.Row="1"
Grid.Column="1"
Text="{Binding TournamentName, UpdateSourceTrigger=PropertyChanged}"
@@ -80,11 +81,15 @@
FontSize="16"
VerticalContentAlignment="Center"
HorizontalAlignment="Left"
Loaded="ComboBox_Loaded"
SelectionChanged="ComboBox_SelectionChanged">
ItemsSource="{Binding CompetitionList}">
<!--<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Source=}"/>
</DataTemplate>
</ComboBox.ItemTemplate>-->
</ComboBox>
<Image Name="CompetitionImage"
<Image x:Name="CompetitionImage"
Grid.Row="2"
Grid.Column="1"
Grid.RowSpan="2"
@@ -93,7 +98,7 @@
HorizontalAlignment="Right"
Margin="0 0 80 0"
Source="{Binding CompetitionImage, Mode=TwoWay, TargetNullValue={x:Null}}" />
<DatePicker SelectedDateFormat="Long"
Grid.Row="3"
SelectedDate="{Binding StartDate}"
@@ -101,7 +106,7 @@
Height="30"
FontSize="14"
HorizontalAlignment="Left"/>
<DatePicker SelectedDateFormat="Long"
Grid.Row="4"
SelectedDate="{Binding EndDate}"
@@ -135,7 +140,7 @@
TextAlignment="Center"
FontSize="14"
Foreground="Red"
Visibility="{Binding HasErrorMessage, Converter= {StaticResource BooleanToVisibilityConverter}}"/>
Visibility="{Binding HasErrorMessage, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<Grid Grid.Row="7"
Grid.ColumnSpan="2"
@@ -155,7 +160,7 @@
Height="35"
FontSize="16"
IsEnabled="{Binding CanSubmit}"/>
<Button Content="Abbrechen"
Command="{Binding CancelCommand}"
Style="{StaticResource ModernButton}"

View File

@@ -25,39 +25,7 @@ namespace Apollon.WPF.Views.Components
{
InitializeComponent();
}
private void ComboBox_Loaded(object sender, RoutedEventArgs e)
{
List<string> competitions = new List<string>()
{
"Halle", "im Freien", "Feld", "3D"
};
ComboBox.ItemsSource = competitions;
}
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (ComboBox.SelectedIndex == 0)
{
CompetitionImage.Source = new BitmapImage(new Uri(@"D:\Projekte\Apollon\Apollon\Apollon.WPF\Images\TargetHall.png"));
}
if (ComboBox.SelectedIndex == 1)
{
CompetitionImage.Source = new BitmapImage(new Uri("D:\\Projekte\\Apollon\\Apollon\\Apollon.WPF\\Images\\TargetField.png"));
}
if (ComboBox.SelectedIndex == 2)
{
CompetitionImage.Source = new BitmapImage(new Uri("D:\\Projekte\\Apollon\\Apollon\\Apollon.WPF\\Images\\TargetOutdoor.png"));
}
if (ComboBox.SelectedIndex == 3)
{
CompetitionImage.Source = new BitmapImage(new Uri("D:\\Projekte\\Apollon\\Apollon\\Apollon.WPF\\Images\\3D.png"));
}
}
}
}
}
}