<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="OMControl.Views.MainWindow"
        xmlns:vm="clr-namespace:OMControl.ViewModels"
        x:DataType="vm:MainWindowViewModel"
        Width="900" Height="600"
        MinWidth="900" MinHeight="600"
        MaxWidth="900" MaxHeight="600"
        CanResize="False"
        Title="Data Entry Form">

  <DockPanel Margin="16" LastChildFill="True">

<Border DockPanel.Dock="Top"
        Margin="0,0,0,12"
        Padding="10"
        BorderBrush="Gray"
        BorderThickness="1"
        CornerRadius="6">
  <StackPanel Spacing="8">
    <TextBlock Text="Serial Port" FontWeight="Bold" Margin="0,0,0,6"/>

    <StackPanel Orientation="Horizontal" Spacing="8">
      <ComboBox Width="120"
                ItemsSource="{Binding AvailablePorts}"
                SelectedItem="{Binding SelectedPort}" />
      <Button Content="Connect" Command="{Binding ConnectCommand}" />
      <Button Content="Disconnect" Command="{Binding DisconnectCommand}" />
    </StackPanel>

    <StackPanel Orientation="Horizontal" Spacing="8">
      <TextBox Width="200" Text="{Binding SendData}" Watermark="Data to send"/>
      <Button Content="Send" Command="{Binding SendCommand}" />
    </StackPanel>

    <TextBox Height="120" AcceptsReturn="True" IsReadOnly="True" Text="{Binding ReceivedData}" />
  </StackPanel>
</Border>


    <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="0,0,0,12" Spacing="8">
      <Button Content="Clear" Command="{Binding ClearCommand}" />
      <Button Content="Refresh COM" Command="{Binding RefreshPortsCommand}" />
    </StackPanel>

    <ScrollViewer>
      <Grid ColumnDefinitions="180,*" RowDefinitions="Auto,Auto,Auto"
            RowSpacing="8" ColumnSpacing="10">
        <TextBlock Grid.Row="0" Grid.Column="0" Text="Field 01" VerticalAlignment="Center"/>
        <TextBox   Grid.Row="0" Grid.Column="1" Text="{Binding Field01}"/>
        <TextBlock Grid.Row="1" Grid.Column="0" Text="Field 02" VerticalAlignment="Center"/>
        <TextBox   Grid.Row="1" Grid.Column="1" Text="{Binding Field02}"/>
        <TextBlock Grid.Row="2" Grid.Column="0" Text="Field 03" VerticalAlignment="Center"/>
        <TextBox   Grid.Row="2" Grid.Column="1" Text="{Binding Field03}"/>
      </Grid>
    </ScrollViewer>

  </DockPanel>
</Window>
