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.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -10,6 +12,7 @@ namespace Apollon.WPF.ViewModels
{ {
public class AddEditDetailsViewModel : ViewModelBase public class AddEditDetailsViewModel : ViewModelBase
{ {
private string _organisation; private string _organisation;
public string Organisation public string Organisation
{ {
@@ -37,10 +40,10 @@ namespace Apollon.WPF.ViewModels
OnPropertyChanged(nameof(TournamentName)); OnPropertyChanged(nameof(TournamentName));
OnPropertyChanged(nameof(CanSubmit)); OnPropertyChanged(nameof(CanSubmit));
} }
} }
private string _competition; private string _competition;
public string Competition public string Competition
{ {
get get
{ {
@@ -49,11 +52,12 @@ namespace Apollon.WPF.ViewModels
set set
{ {
_competition = value; _competition = value;
OnPropertyChanged(nameof(Competition)); OnPropertyChanged(nameof(Competition));
} }
} }
private string _competitionImage; private string _competitionImage;
public string CompetitionImage public string CompetitionImage
{ {
get get
@@ -162,11 +166,20 @@ namespace Apollon.WPF.ViewModels
public ICommand SubmitCommand { get; } public ICommand SubmitCommand { get; }
public ICommand CancelCommand { get; } public ICommand CancelCommand { get; }
public ObservableCollection<string> CompetitionList { get; set; }
public AddEditDetailsViewModel(ICommand submitCommand, ICommand cancelCommand) public AddEditDetailsViewModel(ICommand submitCommand, ICommand cancelCommand)
{ {
SubmitCommand = submitCommand; SubmitCommand = submitCommand;
CancelCommand = cancelCommand; 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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Apollon.WPF.Views.Components" xmlns:local="clr-namespace:Apollon.WPF.Views.Components"
xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl" xmlns:custom="clr-namespace:LoadingSpinnerControl;assembly=LoadingSpinnerControl"
xmlns:ViewModels="clr-namespace:Apollon.WPF.ViewModels" x:Class="Apollon.WPF.Views.Components.AddEditDetails"
mc:Ignorable="d"> mc:Ignorable="d">
<UserControl.Resources> <UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -27,27 +28,27 @@
<TextBlock Text="Veranstalter: " <TextBlock Text="Veranstalter: "
Style="{StaticResource ModalTextBlock}"/> Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="1" <TextBlock Grid.Row="1"
Text="Turniername: " Text="Turniername: "
Style="{StaticResource ModalTextBlock}"/> Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="2" <TextBlock Grid.Row="2"
Text="Wettkampfart: " Text="Wettkampfart: "
Style="{StaticResource ModalTextBlock}"/> Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="3" <TextBlock Grid.Row="3"
Text="Startdatum: " Text="Startdatum: "
Style="{StaticResource ModalTextBlock}"/> Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="4" <TextBlock Grid.Row="4"
Text="Enddatum: " Text="Enddatum: "
Style="{StaticResource ModalTextBlock}"/> Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="5" <TextBlock Grid.Row="5"
Text="Veranstaltungsort: " Text="Veranstaltungsort: "
Style="{StaticResource ModalTextBlock}"/> Style="{StaticResource ModalTextBlock}"/>
<TextBlock Grid.Row="6" <TextBlock Grid.Row="6"
Text="Durchgänge: " Text="Durchgänge: "
Style="{StaticResource ModalTextBlock}"/> Style="{StaticResource ModalTextBlock}"/>
@@ -59,7 +60,7 @@
Height="30" Height="30"
Background="LightGray" Background="LightGray"
VerticalContentAlignment="Center"/> VerticalContentAlignment="Center"/>
<TextBox Grid.Row="1" <TextBox Grid.Row="1"
Grid.Column="1" Grid.Column="1"
Text="{Binding TournamentName, UpdateSourceTrigger=PropertyChanged}" Text="{Binding TournamentName, UpdateSourceTrigger=PropertyChanged}"
@@ -80,11 +81,15 @@
FontSize="16" FontSize="16"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Loaded="ComboBox_Loaded" ItemsSource="{Binding CompetitionList}">
SelectionChanged="ComboBox_SelectionChanged"> <!--<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Source=}"/>
</DataTemplate>
</ComboBox.ItemTemplate>-->
</ComboBox> </ComboBox>
<Image Name="CompetitionImage" <Image x:Name="CompetitionImage"
Grid.Row="2" Grid.Row="2"
Grid.Column="1" Grid.Column="1"
Grid.RowSpan="2" Grid.RowSpan="2"
@@ -93,7 +98,7 @@
HorizontalAlignment="Right" HorizontalAlignment="Right"
Margin="0 0 80 0" Margin="0 0 80 0"
Source="{Binding CompetitionImage, Mode=TwoWay, TargetNullValue={x:Null}}" /> Source="{Binding CompetitionImage, Mode=TwoWay, TargetNullValue={x:Null}}" />
<DatePicker SelectedDateFormat="Long" <DatePicker SelectedDateFormat="Long"
Grid.Row="3" Grid.Row="3"
SelectedDate="{Binding StartDate}" SelectedDate="{Binding StartDate}"
@@ -101,7 +106,7 @@
Height="30" Height="30"
FontSize="14" FontSize="14"
HorizontalAlignment="Left"/> HorizontalAlignment="Left"/>
<DatePicker SelectedDateFormat="Long" <DatePicker SelectedDateFormat="Long"
Grid.Row="4" Grid.Row="4"
SelectedDate="{Binding EndDate}" SelectedDate="{Binding EndDate}"
@@ -135,7 +140,7 @@
TextAlignment="Center" TextAlignment="Center"
FontSize="14" FontSize="14"
Foreground="Red" Foreground="Red"
Visibility="{Binding HasErrorMessage, Converter= {StaticResource BooleanToVisibilityConverter}}"/> Visibility="{Binding HasErrorMessage, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<Grid Grid.Row="7" <Grid Grid.Row="7"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
@@ -155,7 +160,7 @@
Height="35" Height="35"
FontSize="16" FontSize="16"
IsEnabled="{Binding CanSubmit}"/> IsEnabled="{Binding CanSubmit}"/>
<Button Content="Abbrechen" <Button Content="Abbrechen"
Command="{Binding CancelCommand}" Command="{Binding CancelCommand}"
Style="{StaticResource ModernButton}" Style="{StaticResource ModernButton}"

View File

@@ -25,39 +25,7 @@ namespace Apollon.WPF.Views.Components
{ {
InitializeComponent(); 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"));
}
}
}
} }