Fix bindings
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:ExeLauncher.GUI"
|
xmlns:local="clr-namespace:ExeLauncher.GUI"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
d:DataContext="{d:DesignInstance local:ApplicationModel}"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@@ -20,15 +20,15 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<!--Path-->
|
<!--Path-->
|
||||||
<TextBlock Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5" Text="Path:" />
|
<TextBlock Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5" Text="Path:" />
|
||||||
<TextBox Grid.Column="1" Grid.Row="0" Margin="5" VerticalContentAlignment="Center" Text="{Binding ApplicationPath}" />
|
<TextBox Grid.Column="1" Grid.Row="0" Margin="5" VerticalContentAlignment="Center" Text="{Binding Path}" />
|
||||||
<Button Grid.Column="2" Grid.Row="0" Margin="5" Padding="5,2" Content="Browse" Click="Button_Path" />
|
<Button Grid.Column="2" Grid.Row="0" Margin="5" Padding="5,2" Content="Browse" Click="Button_Path" />
|
||||||
|
|
||||||
<!--Arguments-->
|
<!--Arguments-->
|
||||||
<TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5" Text="Arugments:" />
|
<TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5" Text="Arugments:" />
|
||||||
<TextBox Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" Margin="5" VerticalContentAlignment="Center" Text="{Binding ApplicationArguments}" />
|
<TextBox Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" Margin="5" VerticalContentAlignment="Center" Text="{Binding Arguments}" />
|
||||||
|
|
||||||
<!--Working Directory-->
|
<!--Working Directory-->
|
||||||
<TextBlock Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5" Text="Working Directory:" />
|
<TextBlock Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5" Text="Working Directory:" />
|
||||||
<TextBox Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" Margin="5" VerticalContentAlignment="Center" Text="{Binding ApplicationWorkingDirectory}" />
|
<TextBox Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" Margin="5" VerticalContentAlignment="Center" Text="{Binding WorkingDirectory}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ namespace ExeLauncher.GUI
|
|||||||
public AppControl()
|
public AppControl()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
//DataContext = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Path(object sender, RoutedEventArgs e)
|
private void Button_Path(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -1,16 +1,81 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ExeLauncher.GUI
|
namespace ExeLauncher.GUI
|
||||||
{
|
{
|
||||||
public record ApplicationModel
|
public record ApplicationModel : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public int Number { get; set; } = 1;
|
private int _number = 1;
|
||||||
public string Path { get; set; } = "";
|
public int Number
|
||||||
public string Arguments { get; set; } = "";
|
{
|
||||||
public string WorkingDirectory { get; set; } = "";
|
get => _number;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_number != value)
|
||||||
|
{
|
||||||
|
_number = value;
|
||||||
|
|
||||||
|
NotifyPropertyChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _path = "";
|
||||||
|
public string Path
|
||||||
|
{
|
||||||
|
get => _path;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_path != value)
|
||||||
|
{
|
||||||
|
_path = value;
|
||||||
|
|
||||||
|
NotifyPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _arguments = "";
|
||||||
|
public string Arguments
|
||||||
|
{
|
||||||
|
get => _arguments;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_arguments != value)
|
||||||
|
{
|
||||||
|
_arguments = value;
|
||||||
|
|
||||||
|
NotifyPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _workingDirectory = "";
|
||||||
|
public string WorkingDirectory
|
||||||
|
{
|
||||||
|
get => _workingDirectory;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_workingDirectory != value)
|
||||||
|
{
|
||||||
|
_workingDirectory = value;
|
||||||
|
|
||||||
|
NotifyPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
|
|
||||||
|
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
|
||||||
|
{
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<GroupBox Header="{Binding Number}" HeaderStringFormat="Application {0}">
|
<GroupBox Header="{Binding Number}" HeaderStringFormat="Application {0}">
|
||||||
<local:AppControl ApplicationPath="{Binding Path}" ApplicationArguments="{Binding Arguments}" ApplicationWorkingDirectory="{Binding WorkingDirectory}" />
|
<local:AppControl ApplicationPath="{Binding Path, Mode=TwoWay}" ApplicationArguments="{Binding Arguments, Mode=TwoWay}" ApplicationWorkingDirectory="{Binding WorkingDirectory, Mode=TwoWay}" />
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
|
|||||||
Reference in New Issue
Block a user