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(() =>
|
||||
{
|
||||
EditServerConfigurationWindow window = new() { DataContext = this, New = false };
|
||||
EditServerConfigurationWindow window = new(
|
||||
new ViewModels.EditServerConfigurationViewModel(this))
|
||||
{ New = false };
|
||||
window.Show();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,15 @@
|
|||
xmlns:vm="clr-namespace:pgLabII.ViewModels"
|
||||
x:DataType="vm:EditServerConfigurationViewModel"
|
||||
x:Class="pgLabII.Views.EditServerConfigurationWindow"
|
||||
Title="EditServerConfiguration">
|
||||
Title="EditServerConfiguration"
|
||||
SizeToContent="WidthAndHeight">
|
||||
<Design.DataContext>
|
||||
<!-- 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) -->
|
||||
<vm:EditServerConfigurationViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Top">
|
||||
<StackPanel >
|
||||
<TextBlock>Name:</TextBlock>
|
||||
<TextBox Text="{Binding Configuration.Name}"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ namespace pgLabII.Views;
|
|||
|
||||
public partial class EditServerConfigurationWindow : Window
|
||||
{
|
||||
public EditServerConfigurationWindow()
|
||||
public EditServerConfigurationWindow(EditServerConfigurationViewModel? viewModel = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DataContext = new EditServerConfigurationViewModel(
|
||||
DataContext = viewModel ?? new EditServerConfigurationViewModel(
|
||||
new());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue