EditConfiguration pass the correct data to show to the viewmodel. Autosize the window to its contents
This commit is contained in:
parent
1173bfe81e
commit
fb7dac642a
3 changed files with 8 additions and 5 deletions
|
|
@ -61,7 +61,9 @@ public class ServerConfiguration : ReactiveObject
|
||||||
{
|
{
|
||||||
EditCommand = ReactiveCommand.Create(() =>
|
EditCommand = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
EditServerConfigurationWindow window = new() { DataContext = this, New = false };
|
EditServerConfigurationWindow window = new(
|
||||||
|
new ViewModels.EditServerConfigurationViewModel(this))
|
||||||
|
{ New = false };
|
||||||
window.Show();
|
window.Show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,15 @@
|
||||||
xmlns:vm="clr-namespace:pgLabII.ViewModels"
|
xmlns:vm="clr-namespace:pgLabII.ViewModels"
|
||||||
x:DataType="vm:EditServerConfigurationViewModel"
|
x:DataType="vm:EditServerConfigurationViewModel"
|
||||||
x:Class="pgLabII.Views.EditServerConfigurationWindow"
|
x:Class="pgLabII.Views.EditServerConfigurationWindow"
|
||||||
Title="EditServerConfiguration">
|
Title="EditServerConfiguration"
|
||||||
|
SizeToContent="WidthAndHeight">
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||||
<vm:EditServerConfigurationViewModel />
|
<vm:EditServerConfigurationViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Top">
|
<StackPanel >
|
||||||
<TextBlock>Name:</TextBlock>
|
<TextBlock>Name:</TextBlock>
|
||||||
<TextBox Text="{Binding Configuration.Name}"/>
|
<TextBox Text="{Binding Configuration.Name}"/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ namespace pgLabII.Views;
|
||||||
|
|
||||||
public partial class EditServerConfigurationWindow : Window
|
public partial class EditServerConfigurationWindow : Window
|
||||||
{
|
{
|
||||||
public EditServerConfigurationWindow()
|
public EditServerConfigurationWindow(EditServerConfigurationViewModel? viewModel = null)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
DataContext = new EditServerConfigurationViewModel(
|
DataContext = viewModel ?? new EditServerConfigurationViewModel(
|
||||||
new());
|
new());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue