mauede
Well-known member
Thank you for all the help you have given me.
I added a couple of new features upon requests from my colleagues.
It does what it is supposed to do. However, it looks ugly.
I tried to make it more compact but WPF but I couldn't. For some reason, that I don't get, if I move horizontally one of the ListBoxes then other untouched controls move
as well. I moved to the right the two bottom buttons ("Cancel", "Commit") and the above ListBoxes moved too. Eventually, the 5th one got out of the window.
What are the best techniques to resize/move some controls on the window without disrupting the whole GUI?
In the attached picture I am showing what I could achieve partially by editing the XAML file and partially by editing the controls through the more, directly on the window.
I watched some videos posted by professionals that made building a GUI look so easy. But it was not easy for me just to produce something that does not look good at all.
What am I missing?
I am attaching my XAML file.
Thank you so much
XML:
<Window x:Class="WPFUI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFUI"
mc:Ignorable="d" FontSize="20"
Title="RT Structure Renaming" Height="900" Width="1704" Background="#FFE3EECD">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<Label x:Name="TrialName" Grid.Row="1" Height=" 50" VerticalAlignment="Top" Content=" Trial Name" FontFamily="Arial Black" FontWeight="Bold" FontSize="20"
Grid.ColumnSpan="2" Margin="0,10,0,0" HorizontalAlignment="Left" Width="146" />
<TextBox x:Name="Trial" Grid.Column="1" MinWidth="80" Height="40" VerticalAlignment="Top" FontFamily="Arial Black" FontSize="20"
TextChanged="Trial_TextChanged" Text="" DataContextChanged="Trial_DataContextChanged" Margin="124,10,151,0" Grid.Row="1" Grid.ColumnSpan="21" />
<Button x:Name="SearchDB" Grid.Row="1" Height="45" Content= "Protocol Structures" HorizontalAlignment="Center" VerticalAlignment="Top" FontFamily="Arial Black"
FontSize="20" Margin="0,55,0,0" Click="SearchDB_Click" Grid.RowSpan="2" Grid.Column="1" Width="220" Background="Gold" />
<Label x:Name="PatientID" Grid.Column="21" Content="Patient Id" Margin="100,6,2,0" VerticalAlignment="Top" FontFamily="Arial Black" FontWeight="Bold" FontSize="20" Height="50" Grid.Row="1" />
<TextBox x:Name="Patient" Grid.Column="22" Grid.Row="1" MinWidth="100" Text="{Binding PatientName, Mode=OneWay}" FontFamily="Arial Black" FontSize="20"
Margin="10,12,0,0" VerticalAlignment="Top" Height="38" TextChanged="Patient_TextChanged" HorizontalAlignment="Left" Width="260" Grid.ColumnSpan="15" />
<Button x:Name="PatientScan" Grid.Column="20" Grid.Row="1" Content="Load CTs and RT Structures" HorizontalAlignment="Right"
Margin="0,55,10,0" FontFamily="Arial Black" FontSize="20" Grid.ColumnSpan="3" Click="PatientScan_Click" Grid.RowSpan="2" Width="312" />
<Separator/>
<ComboBox x:Name="VDB" Grid.Row="6" Grid.Column="21" MinWidth="100" Height="60" Grid.ColumnSpan="2"
ItemsSource="{Binding Path=velocityDB, Mode=OneWay}" SelectedItem="VelocityDB"
Background="Orchid" Margin="100,5,0,5" HorizontalAlignment="Left" Width="200" SelectionChanged="VDB_SelectionChanged" >
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="VDB" Text="{Binding MyVelocityDB}" Grid.Column="0" Padding="10,5" HorizontalAlignment="Center" FontFamily="Arial Black" FontSize="22" />
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Label Grid.Column="1" Content="Velocity Database" HorizontalAlignment="Left" Margin="63,0,0,0" Grid.Row="6" VerticalAlignment="Center" Width="239"
Grid.ColumnSpan="21" FontFamily="Arial Black" FontWeight="Bold" FontSize="22" Height="40" Background="OldLace" />
<Button x:Name="Cancel" Grid.Column="23" Grid.Row="6" Height="66" Content=" Cancel" HorizontalAlignment="Left" Background="Red"
Margin="113,10,0,0" VerticalAlignment="Top" FontFamily="Arial Black" FontSize="20" Width="139" Click="Cancel_Click" />
<Button x:Name="Confirm" Grid.Column="23" Grid.Row="6" Height="66" Content=" Commit" HorizontalAlignment="Left" Background="Blue"
Margin="308,10,0,0" VerticalAlignment="Top" FontFamily="Arial Black" FontSize="20" Width="117" Click="Accept_Click" Grid.ColumnSpan="3" />
<Label Grid.Column="23" Content="Patient Structures" HorizontalAlignment="Left" Margin="52,60,0,0" Grid.Row="1" VerticalAlignment="Top"
FontFamily="Arial Black" FontWeight="Bold" FontSize="22" Height="40" Grid.RowSpan="2" Width="233" />
<Label Grid.Column="24" Content="Auto Renamed Structures" HorizontalAlignment="Left" Margin="32,60,0,0" Grid.Row="1" VerticalAlignment="Top" Grid.ColumnSpan="113"
FontFamily="Arial Black" FontWeight="Bold" FontSize="22" Height="40" Grid.RowSpan="2" Width="324" />
<Button x:Name="AutoMatchedStruct" Grid.Column="23" Content="Load Auto-Matched Structures" HorizontalAlignment="Left" Margin="181,12,0,0" Grid.Row="1" VerticalAlignment="Top" Height="43" Width="456"
Grid.ColumnSpan="7" FontFamily="Arial Black" FontSize="20" Background="Wheat" Click="AutoMatchedStruct_Click" />
<ListBox x:Name="ProtocolStructures" Grid.Column="1" Grid.Row="5" d:ItemsSource="{d:SampleData}" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.CanContentScroll="True"
Margin="0,20,0,40" HorizontalAlignment="Left" Width="210" Height="600" Background="LawnGreen" />
<ListBox x:Name="CTnames" Grid.Column="21" Grid.Row="5" d:ItemsSource="{d:SampleData}" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.CanContentScroll="True" Margin="10,20,0,40"
SelectionMode="Single" SelectionChanged="CTnames_SelectionChanged" HorizontalAlignment="Left" Width="187" Height="600" Background="SandyBrown" />
<ListBox x:Name="StructSets" Grid.Column="22" Grid.Row="5" d:ItemsSource="{d:SampleData}" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.CanContentScroll="True"
Margin="0,15,26,45" SelectionMode="Single" HorizontalAlignment="Right" Width="200" SelectionChanged="StructSets_SelectionChanged" Height="600" Background="PaleGoldenrod" />
<ListBox x:Name="VelStructures" Grid.Column="23" Grid.Row="5" d:ItemsSource="{d:SampleData}" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.CanContentScroll="True"
Margin="0,14,39,46" Height="600" SelectionMode="Single" Background="Yellow" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Right" Width="233" >
<ListBox.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform AngleY="0.851"/>
<RotateTransform/>
<TranslateTransform Y="1.485"/>
</TransformGroup>
</ListBox.RenderTransform>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Name="TextNum" Text="{Binding Num, Mode=OneWay}" Grid.Column="0" Padding="1,5" HorizontalAlignment="Stretch" />
<TextBox Text="{Binding Name, Mode=OneWay}" Grid.Column="1" HorizontalAlignment="Stretch" IsReadOnly="True" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox x:Name="EditableStructs" Grid.Row="5" Grid.Column="25" Margin="10,20,0,40" SelectionMode="Single" Grid.ColumnSpan="3" Background="PowderBlue"
ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.CanContentScroll="True" ItemsSource="{Binding AutoNames,Mode=TwoWay}" Height="600" HorizontalAlignment="Left" Width="229" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Name="TextInd" Text="{Binding NamInd, Mode=OneWay}" Grid.Column="0" Padding="1,5" HorizontalAlignment="Stretch"/>
<CheckBox IsChecked="{Binding IsAccepted, Mode=TwoWay}" Grid.Column="1" Padding="5,5" VerticalAlignment="Center" HorizontalAlignment="Center" />
<TextBox Text="{Binding StrName, Mode=TwoWay}" Grid.Column="2" HorizontalAlignment="Stretch"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
Last edited: