Related
I have an incredible annoying problem with accordion content template.
It shows perfectly, no problem with databinding or something else, but when i resize the browser window the tabControl inside the detail of the accordion doesn't resize at all.
It seems like the width is fixed but acctually it's not.
When the listbox has to change data because of the databinding, the tabcontrol resize perfectly to the new browser window size. Any suggestions please?
My code is:
<layoutToolkit:Accordion.ContentTemplate>
<DataTemplate>
<!--#Sinergia Wave2-->
<Grid>
<sdk:TabControl Grid.Row="1" Grid.ColumnSpan="4" Loaded="ListBox_Loaded" SizeChanged="ListaDetailControlli_SizeChanged">
<sdk:TabItem Header="Controlli">
<Grid Visibility="{Binding HasItems, Converter={StaticResource ConvertBooleanToVisible}}">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition Width="300" />
<!--Colonna del semaforo -->
<ColumnDefinition Width="44" />
<ColumnDefinition Width="300*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.ColumnSpan="4" Orientation="Horizontal">
<Grid SizeChanged="Grid_SizeChanged" Background="#FFC1C1C1" Height="25">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition Width="300" />
<!--Colonna del semaforo -->
<ColumnDefinition Width="44" />
<ColumnDefinition Width="300*" />
</Grid.ColumnDefinitions>
<dataInput:Label Grid.Column="1" FontSize="12" FontWeight="Bold" Content="Controllo" HorizontalAlignment="Left" VerticalAlignment="Center" />
<dataInput:Label Grid.Column="3" FontSize="12" FontWeight="Bold" Content="Dettagli" HorizontalAlignment="Left" VerticalAlignment="Center" />
</Grid>
</StackPanel>
<ListBox Name="ListaDetailControlli" BorderThickness="0" Grid.Row="1" Grid.ColumnSpan="4" ItemsSource="{Binding ListaControlli}" SelectionMode="Single"
SelectedItem="{Binding SelectedTask, Mode=TwoWay}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="44" />
<ColumnDefinition Width="300*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" FontSize="10" Margin="2,0,4,0" VerticalAlignment="Center" HorizontalAlignment="Stretch" TextAlignment="Left"
Text="{Binding DescrizioneControllo}" />
<Canvas Grid.Column="1"
Width="22"
Height="22"
Margin="0,0,4,0">
<Image Source="/Image/Traffic-no-light.png"
Width="22"
Height="22"
Margin="0,0,4,0" />
<Ellipse Canvas.Left="7"
Canvas.Top="2"
Width="8"
Height="8"
Fill="{Binding ColoreControllo}" />
<Ellipse Canvas.Left="7"
Canvas.Top="11"
Width="8"
Height="8"
Fill="{Binding ColoreControllo}" />
</Canvas>
<!-- #135162;dv;; Pannello Controlli -->
<TextBlock Grid.Column="2" FontSize="10" Margin="2,0,4,0" TextAlignment="Left" Text="{Binding DettaglioControllo}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</sdk:TabItem>
<sdk:TabItem Header="Task" GotFocus="TabTask_GotFocus">
<Grid VerticalAlignment="Stretch">
<Border BorderThickness="0" VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Foreground="Red" FontSize="18" FontWeight="Bold" Text="Non è presente nessun task per il giorno selezionato" TextWrapping="Wrap"
Visibility="{Binding Path=HasTask, Converter={StaticResource ConvertBooleanToVisibleNegato}}" />
</Border>
<ScrollViewer BorderThickness="0" Visibility="{Binding Path=HasTask, Converter={StaticResource ConvertBooleanToVisible}}">
<ListBox x:Name="ListaTask" BorderThickness="0" Tag="{Binding ID_SERBATOIO}" MinWidth="250" Margin="-2,-1,-2,0" HorizontalAlignment="Stretch"
ItemContainerStyle="{StaticResource CheckBoxItemContainerStyleWithStatusDiari}" ItemsSource="{Binding ListaTask}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0">
<StackPanel>
<Border x:Name="BorderDrop" Height="20" Margin="8,0,0,0" Background="Gray" BorderThickness="4" Canvas.ZIndex="-2" CornerRadius="9"
Opacity="0.8" Padding="0" Visibility="Collapsed">
<Border.BorderBrush>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Offset="0.2" Color="Black" />
<GradientStop Offset="0.8" Color="#FFCDCCCC" />
</LinearGradientBrush>
</Border.BorderBrush>
</Border>
<controlsLIB:TaskMultiTemp DataContext="{Binding }" PannelloOspitante="{Binding LayoutOspitante,ElementName=panValidazioneOperatori,
Mode=OneWay}"
TemplateTipo="{Binding TemplateMultiTemp,ElementName=panValidazioneOperatori,Mode=OneWay}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
</Grid>
</sdk:TabItem>
</sdk:TabControl>
</Grid>
</DataTemplate>
I'm writing a UWP app and have a page with a full-page grid inside a scrollviewer with two even-width outer columns and two even-width inner columns. The right side of the page is a mirror of the left, and everything is aligned to the similar column on the opposite side. However, when I run my app and decrease the width, after a certain point only the third column shrinks. Before that point, all the columns adjust correctly. I don't have any width or minwidth properties set. If I set a fixed width on my grid, the columns resize to be even. I've tried changing which columns my elements are aligned to on various elements, removing the ScrollViewer, and double- and triple-checking for any min-widths being set anywhere.
<ScrollViewer HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Grid MinWidth="800" Background="{ThemeResource SystemControlBackgroundAccentBrush}" ManipulationMode="All">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="69*"/>
<ColumnDefinition Width="76*"/>
<ColumnDefinition Width="76*"/>
<ColumnDefinition Width="69*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="27*"/>
<RowDefinition Height="62*"/>
<RowDefinition Height="27*"/>
<RowDefinition Height="399*"/>
<RowDefinition Height="340*"/>
<RowDefinition Height="105*"/>
</Grid.RowDefinitions>
<Viewbox Margin="100,27,89.667,0" Grid.RowSpan="3" Height="63" VerticalAlignment="Top" Stretch="Uniform">
<RichTextBlock Foreground="White">
<Paragraph>
<Run Text="Home" FontSize="48" FontWeight="Bold" FontStretch="Normal"/>
</Paragraph>
</RichTextBlock>
</Viewbox>
<Viewbox Margin="90,27,100,0" Grid.RowSpan="3" Grid.Column="3" Height="63" VerticalAlignment="Top">
<RichTextBlock Foreground="White">
<Paragraph>
<Run Text="Away" FontSize="48" FontWeight="Bold"/>
</Paragraph>
</RichTextBlock>
</Viewbox>
<Rectangle Fill="White" Margin="0,0,-1,0" Stroke="#FF252525" Grid.RowSpan="6" HorizontalAlignment="Right" Width="2" Grid.Column="1"/>
<Button x:Name="HomeGoalBtn" Margin="320,0,0.667,0.667" Grid.Row="3" Click="button_Click" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.ColumnSpan="2">
<RichTextBlock IsTextSelectionEnabled="False">
<Paragraph>
<Run Text="Goal" FontSize="48" Foreground="White" />
</Paragraph>
</RichTextBlock>
</Button>
<Button x:Name="AwayGoalBtn" HorizontalAlignment="Stretch" Margin="0.333,0,320,0.667" Grid.Row="3" VerticalAlignment="Stretch" Click="button_Click" Grid.ColumnSpan="2" Grid.Column="2">
<RichTextBlock IsTextSelectionEnabled="False">
<Paragraph>
<Run Text="Goal" FontSize="48" Foreground="White" />
</Paragraph>
</RichTextBlock>
</Button>
<Button x:Name="AwayShotBtn" Content="Button" HorizontalAlignment="Stretch" Margin="0.333,24.333,25,15" Grid.Row="4" VerticalAlignment="Stretch" Grid.Column="2"/>
<Button x:Name="AwayPenaltyBtn" Content="Button" HorizontalAlignment="Stretch" Margin="30,104.333,112,15" Grid.Row="4" VerticalAlignment="Stretch" Grid.Column="3"/>
<RichTextBlock Margin="10,10,0,0.667" Grid.Row="3" HorizontalAlignment="Left" Width="310">
<Paragraph TextAlignment="Center">
<Run Text="{x:Bind ViewModel.HomeScore, Mode=OneWay}" FontSize="200"/>
</Paragraph>
</RichTextBlock>
<RichTextBlock Margin="0,0,0,0.667" Grid.Row="3" Grid.Column="3" HorizontalAlignment="Right" Width="320">
<Paragraph TextAlignment="Center">
<Run Text="{x:Bind ViewModel.AwayScore, Mode=OneWay}" FontSize="200"/>
</Paragraph>
</RichTextBlock>
<Button x:Name="HomeShotBtn" Content="Button" HorizontalAlignment="Stretch" Margin="30.333,24.667,0,14.333" Grid.Row="4" VerticalAlignment="Stretch" Grid.Column="1" />
<Button x:Name="HomePenaltyBtn" Content="Button" HorizontalAlignment="Stretch" Margin="102,104.333,24.667,15" Grid.Row="4" VerticalAlignment="Stretch"/>
<Button x:Name="MenuBtn" Content="Button" Grid.Column="1" HorizontalAlignment="Left" Margin="30.333,20.167,0,8" Grid.Row="5" VerticalAlignment="Stretch" Width="250" Click="button3_Click"/>
</Grid>
</ScrollViewer>
This is how my page looks in the designer:
OK... it appears to me that the layout is overconstrained - likely due to a lot of Blend arranging (a lot of crazy margins in there). If you want predictable layouts, I would recommend positioning the controls within the bounds of the grid sections that you expect to see them rather than trying to use margins to position them. Basically, which grid section do you want the element (Grid.Row=# Grid.Column=#), how many sections does it span (Grid.RowSpan=# Grid.ColumnSpan=#), which edges to align to (HorizontalAlignment=Left/Right/Center/Stretch VerticalAlignment=Left/Right/Center/Stretch), and how much space do you want from the edges (Margin=# # # #)?
So,
<Viewbox Margin="100,27,89.667,0" Grid.RowSpan="3" Height="63" VerticalAlignment="Top" Stretch="Uniform">
<RichTextBlock Foreground="White">
<Paragraph>
<Run Text="Home" FontSize="48" FontWeight="Bold" FontStretch="Normal"/>
</Paragraph>
</RichTextBlock>
</Viewbox>
Becomes,
<Viewbox >
<TextBlock Text="Home" Foreground="White" FontSize="48" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Bottom" />
</Viewbox>
Additionally, I'm not sure you need the viewboxes, richtextboxes, and paragraphs with runs for what you are doing, but I do not know the entire scope of what you're trying to accomplish.
Try something like the following:
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
<Grid MinWidth="800" MinHeight="600" Background="{ThemeResource SystemControlBackgroundAccentBrush}" ManipulationMode="All">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="69*"/>
<ColumnDefinition Width="76*"/>
<ColumnDefinition Width="76*"/>
<ColumnDefinition Width="69*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="27*"/>
<RowDefinition Height="62*"/>
<RowDefinition Height="27*"/>
<RowDefinition Height="399*"/>
<RowDefinition Height="340*"/>
<RowDefinition Height="105*"/>
</Grid.RowDefinitions>
<Viewbox >
<TextBlock Text="Home" Foreground="White" FontSize="48" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Bottom" />
</Viewbox>
<Viewbox Grid.Column="3">
<TextBlock Text="Away" Foreground="White" FontSize="48" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Bottom" />
</Viewbox>
<Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="3" Grid.Column="1" >
<TextBlock Text="Home" Foreground="White" FontSize="48" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Bottom" />
</Button>
<Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="3" Grid.Column="2" >
<TextBlock Text="Away" Foreground="White" FontSize="48" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Bottom" />
</Button>
<Button x:Name="HomeShotBtn" Content="Button" Margin="15" HorizontalAlignment="Stretch" Grid.Row="4" VerticalAlignment="Stretch" Grid.Column="1"/>
<Button x:Name="HomePenaltyBtn" Content="Button" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="15" Grid.Row="4" Grid.Column="0"/>
<Button x:Name="AwayShotBtn" Content="Button" Margin="15" HorizontalAlignment="Stretch" Grid.Row="4" VerticalAlignment="Stretch" Grid.Column="2"/>
<Button x:Name="AwayPenaltyBtn" Content="Button" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="15" Grid.Row="4" Grid.Column="3"/>
<TextBlock Text="24" Grid.Row="3" FontSize="200" HorizontalAlignment="Left" VerticalAlignment="Center" />
<TextBlock Text="12" Grid.Row="3" Grid.Column="3" FontSize="200" HorizontalAlignment="Right" VerticalAlignment="Center" />
<Button x:Name="MenuBtn" Content="Button" Grid.Column="1" HorizontalAlignment="Stretch" Margin="15" Grid.Row="5" VerticalAlignment="Stretch" />
</Grid>
</ScrollViewer>
I have a problem with the first element in a listbox, the arranging is being changed in it.
This is the code:
<Grid x:Name="ContentPanel" Margin="12,10,0,0" Grid.RowSpan="2" Grid.ColumnSpan="2">
<ListBox Margin="10,233,10,0" BorderBrush="White" Hold="ListBox1_Hold" SelectionChanged="ListBox1_SelectionChanged" Height="516" x:Name="ListBox1" VerticalAlignment="Top">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Width="500" Orientation="Vertical" >
<Image Margin="10,30,0,0" HorizontalAlignment="Left" Height="100" Width="150" Source="{Binding Img}" ></Image>
<TextBlock Visibility="Collapsed" Text="ID: "/>
<TextBlock Visibility="Collapsed" Text="{Binding Id}"/>
<TextBlock Visibility="Collapsed" FontSize="30" Text="Place Name: "/>
<TextBlock Margin="160,-110,0,0" HorizontalAlignment="Left" Foreground="Blue" FontSize="30" Text="{Binding PlaceName}"/>
<TextBlock Visibility="Collapsed" Text="Description: "/>
<TextBlock Margin="160,-80,0,0" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Description}" />
<TextBlock Visibility="Collapsed" Text="Keyword: "/>
<TextBlock Visibility="Collapsed" Text="{Binding Keyword}"/>
<TextBlock Visibility="Collapsed" Text="Longitude: "/>
<TextBlock Visibility="Collapsed" Text="{Binding Long}"/>
<TextBlock Visibility="Collapsed" Text="Latitude: "/>
<TextBlock Visibility="Collapsed" Text="{Binding Latit}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
And here the result of this code:
The Picture
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
// First block
<grid grid.colum="0" grid.row="0" grid.rowspan="2"><image></grid>
<grid grid.colum="1" grid.row="0" ><textblock></grid>
<grid grid.colum="1" grid.row="1" ><textblock></grid>
// Seconde block
<grid grid.colum="0" grid.row="1" grid.rowspan="2"><image></grid>
<grid grid.colum="1" grid.row="2" ><textblock></grid>
<grid grid.colum="1" grid.row="3" ><textblock></grid>
// third block
<grid grid.colum="0" grid.row="2" grid.rowspan="2"><image></grid>
<grid grid.colum="1" grid.row="4" ><textblock></grid>
<grid grid.colum="1" grid.row="5" ><textblock></grid>
</Grid>
I am not able to get the Scrollviewer to working in WPF. I guess I am doing something wrong but not able to figure out what. I also made sure that I am not using the ScrollViewer in side a StackPanel. Please note there are 2 of them and none seems to work.
I did try to fix the size of the ScrollViewer parent container to restrict size, which works, but that's not what I want to do. I want to make sure that on resizing the window, the increase of size happens in the containers appropriately.
Here is my code, I did change the strings and paths as this is a part of client application:
<Window x:Class="Common.Views.SomeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wnd="clr-namespace:Common"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:uc="clr-namespace:Library.UI.Core;assembly=Library.UI.Core"
xmlns:cocls="clr-namespace:Library.UI.Core;assembly=Library.UI.Core"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
ToolTipService.ShowOnDisabled="True"
dx:ThemeManager.ThemeName="Office2007Silver"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
ResizeMode="CanResize"
Title="Some Validation" IsTabStop="False"
Height="365"
Width="792" d:Height="700" d:Width="1000">
<Grid Background="{StaticResource BackgroundBrush}" x:Name="SomeGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<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="*"/>
</Grid.RowDefinitions>
<Menu Name="MainMenu" Background="{StaticResource BackgroundBrush}" Grid.Row="0" >
</Menu>
<Rectangle Grid.Row="1" Style="{StaticResource ResourceKey=HorizontalRectangleBorderStyle}" />
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<ToolBarTray HorizontalAlignment="Stretch" FlowDirection="LeftToRight" Background="{StaticResource BackgroundBrush}" Grid.Column="0" x:Name="tlbartrayMaster" >
<ToolBar Background="{StaticResource BackgroundBrush}" Style="{DynamicResource DefaultToolBarStyle}" Width="Auto" x:Name="tlbarMasterImgTools" IsTabStop="False">
<Button Name="NewToolBarButton" x:FieldModifier="public" Style="{StaticResource ResourceKey=ToolBarBtnStyle}"
Command="{x:Static wnd:MyAppCommands.MyAppInsertCommand}" CommandTarget="{Binding ElementName=SomeValidationGrid}"
ToolTip="Insert (F5)" IsTabStop="False"
IsEnabled="{Binding RelativeSource={RelativeSource AncestorType={x:Type wnd:MainWindowBase},
Mode=FindAncestor},Path=CanInsert, Mode=TwoWay}">
<Image Source="pack://application:,,,/Common;component/Images/new.bmp"
Style="{StaticResource ImageOpacityStyle}" Height="16" Width="16" />
</Button>
<Button Name="SaveToolBarButton" x:FieldModifier="public" ToolTip="Save (F2)" Style="{StaticResource ResourceKey=ToolBarBtnStyle}"
IsTabStop="False" ToolTipService.ShowOnDisabled="True"
Command="{x:Static wnd:MyAppCommands.MyAppSaveCommand}" CommandTarget="{Binding ElementName=SomeValidationGrid}"
IsEnabled="{Binding RelativeSource={RelativeSource AncestorType={x:Type wnd:MainWindowBase},
Mode=FindAncestor},Path=CanSave, Mode=TwoWay}">
<Image Source="pack://application:,,,/Common;component/Images/Save.bmp"
Style="{DynamicResource ImageOpacityStyle}" Height="16" Width="16" />
</Button>
<Separator/>
<Button Name="SearchToolBarButton" ToolTip="Search for a specific record (F4)" Style="{StaticResource ResourceKey=ToolBarBtnStyle}"
IsTabStop="False"
Command="{x:Static wnd:MyAppCommands.MyAppSearchCommand}" CommandTarget="{Binding ElementName=SomeValidationGrid}"
IsEnabled="{Binding RelativeSource={RelativeSource AncestorType={x:Type wnd:MainWindowBase},
Mode=FindAncestor},Path=CanSearch, Mode=TwoWay}">
<Image Source="pack://application:,,,/Common;component/Images/Edit.bmp"
Style="{DynamicResource ImageOpacityStyle}" Height="16" Width="16" />
</Button>
<Separator/>
<Button Name="CancelToolBarButton" Focusable="False" x:FieldModifier="public" ToolTip="Cancel (Esc)" Style="{StaticResource
ResourceKey=ToolBarBtnStyle}" IsTabStop="False" ToolTipService.ShowOnDisabled="True"
Command="{x:Static wnd:MyAppCommands.MyAppEscCommand}" CommandTarget="{Binding ElementName=SomeValidationGrid}"
IsEnabled="{Binding RelativeSource={RelativeSource AncestorType={x:Type wnd:MainWindowBase},
Mode=FindAncestor},Path=CanCancel, Mode=TwoWay}">
<Image Source="pack://application:,,,/Common;component/Images/Undo.bmp"
Style="{DynamicResource ImageOpacityStyle}" Height="16" Width="16" />
</Button>
<Button Name="DeleteToolBarButton" x:FieldModifier="public" ToolTip="Delete (Shift+F2)" Style="{StaticResource ResourceKey=ToolBarBtnStyle}"
IsTabStop="False"
Command="{x:Static wnd:MyAppCommands.MyAppDeleteCommand}" CommandTarget="{Binding ElementName=SomeValidationGrid}"
IsEnabled="{Binding RelativeSource={RelativeSource AncestorType={x:Type wnd:MainWindowBase},
Mode=FindAncestor},Path=CanDelete, Mode=TwoWay}">
<Image Source="pack://application:,,,/Common;component/Images/Bin.bmp"
Style="{DynamicResource ImageOpacityStyle}" Height="16" Width="16" />
</Button>
<Separator/>
<Button Name="CalculatorToolBarButton" ToolTip="Activate Calculator" Style="{StaticResource ResourceKey=ToolBarBtnStyle}"
Command="{x:Static wnd:MyAppCommands.MyAppCalculatorCommand}" CommandTarget="{Binding ElementName=SomeValidationGrid}"
IsTabStop="False" IsEnabled="True">
<Image Source="pack://application:,,,/Common;component/Images/Calculator.bmp"
Style="{DynamicResource ImageOpacityStyle}" Height="16" Width="16"/>
</Button>
<Button x:Name="PrintToolBarButton" Style="{StaticResource ResourceKey=ToolBarBtnStyle}" ToolTip="View/Print Report"
IsTabStop="False" >
<Image Source="pack://application:,,,/Common;component/Images/Print.bmp"
Style="{DynamicResource ImageOpacityStyle}" Height="16" Width="16" />
</Button>
<Button x:Name="HelpToolBarButton" Visibility="Collapsed" Style="{StaticResource ResourceKey=ToolBarBtnStyle}"
ToolTip="Access help on current subject" IsTabStop="False" >
<Image Source="pack://application:,,,/Common;component/Images/information.bmp"
Style="{DynamicResource ImageOpacityStyle}" Height="16" Width="16" />
</Button>
<Button x:Name="SearchParticipantToolbarButton" Style="{StaticResource ResourceKey=ToolBarBtnStyle}"
ToolTip="Search for Participant/Entity/Member" IsTabStop="False" >
<Image Source="pack://application:,,,/Common;component/Images/Candle.bmp"
Style="{DynamicResource ImageOpacityStyle}" Height="16" Width="16" />
</Button>
<Separator/>
</ToolBar>
<ToolBar x:Name="MyCompImageToolbar" HorizontalAlignment="Stretch" FlowDirection="LeftToRight" IsTabStop="False"
Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ToolBarTray}}}"
Style="{DynamicResource DefaultToolBarStyle}" MaxHeight="1000" ToolBarTray.IsLocked="True">
<Label x:Name="ToolBarMessageLabel" HorizontalContentAlignment="Center" Foreground="#000084" FontWeight="Bold" Margin="50,0,0,0"/>
</ToolBar>
</ToolBarTray>
<TextBlock Grid.Column="1" >
<Hyperlink NavigateUri="http://MyComp-software.com" Foreground="Transparent" ToolTip="http://MyComp-software.com">
<Image Source="pack://application:,,,/Common;component/Images/MyCompLogo.bmp"
VerticalAlignment="Stretch"
Style="{StaticResource DefaultMenuTabImgStyle}" />
</Hyperlink>
</TextBlock>
</Grid>
<Rectangle Grid.Row="3" Style="{StaticResource ResourceKey=HorizontalRectangleBorderStyle}" />
<Grid Grid.Column="0" Grid.Row="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".5*"/>
<ColumnDefinition Width="1"/>
<ColumnDefinition Width=".5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="ErrorStringGrid" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3">
<TextBlock x:Name="ErrorText" Text="{Binding Path=ErrorString}" Foreground="Red" />
</Grid>
<Grid x:Name="SomeToValidateSectionGrid" Grid.Column="0" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid x:Name="SomeToValidateSection1Grid" Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="Some To Validate" FontWeight="Bold" Grid.Row="0" HorizontalAlignment="Center" />
<ScrollViewer CanContentScroll="True" IsDeferredScrollingEnabled="False" VerticalScrollBarVisibility="Auto" Width="Auto" Grid.Row="1">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock x:Name="txtblSomeBlockToValidate" Foreground="{StaticResource BlueTextBrush}" Height="42" HorizontalAlignment="Center" />
<TextBlock Text="Some Details:" FontWeight="Bold" HorizontalAlignment="Center"/>
<Grid HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="Some1:" Grid.Column="0" Grid.Row="0" />
<TextBlock Text="Some1:" Grid.Column="0" Grid.Row="1" />
<TextBlock Text="Some1:" Grid.Column="0" Grid.Row="2" />
<TextBlock Text="Some1:" Grid.Column="0" Grid.Row="3" />
<TextBlock Text="Some1:" Grid.Column="0" Grid.Row="4" />
<TextBlock Text="Some1:" Grid.Column="0" Grid.Row="5" />
<TextBlock Text="Some1:" Grid.Column="0" Grid.Row="6" />
<TextBlock Text="{Binding Some1}" Grid.Column="1" Grid.Row="0" />
<TextBlock Text="{Binding Some1}" Grid.Column="1" Grid.Row="1" />
<TextBlock Text="{Binding Some1}" Grid.Column="1" Grid.Row="2" />
<TextBlock Text="{Binding Some1}" Grid.Column="1" Grid.Row="3" />
<TextBlock Text="{Binding Some1}" Grid.Column="1" Grid.Row="4" />
<TextBlock Text="{Binding Some1}" Grid.Column="1" Grid.Row="5" />
<TextBlock Text="{Binding Some1}" Grid.Column="1" Grid.Row="6" />
</Grid>
</Grid>
</ScrollViewer>
</Grid>
<Grid x:Name="SomeToValidateSection2Grid" Grid.Row="1">
<Expander Name="MyAppExpander" IsExpanded="False" Height="Auto" Style="{DynamicResource ExpanderStyle4}"
BorderThickness="2" BorderBrush="#FFBA8B8B" Opacity="1" IsTabStop="False" HorizontalAlignment="Stretch">
<Expander.Header>
<StackPanel HorizontalAlignment="Stretch">
<TextBlock Text="More Information" HorizontalAlignment="Center" TextDecorations="Underline" Foreground="#0054E3"/>
</StackPanel>
</Expander.Header>
<Border BorderThickness="1,0,0,0" BorderBrush="#FFBA8B8B" Background="White" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<StackPanel x:Name="panelBanks">
<TextBlock Text="{Binding AdditionalInfo}" HorizontalAlignment="Center" Height="61" />
</StackPanel>
</Border>
</Expander>
</Grid>
</Grid>
<GridSplitter Grid.Row="1" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Center"/>
<Grid x:Name="SuggestedSomeGrid" Grid.Column="2" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="Suggested Validation Some" FontWeight="Bold" Grid.Row="0" HorizontalAlignment="Center"/>
<ScrollViewer CanContentScroll="True" IsDeferredScrollingEnabled="False" VerticalScrollBarVisibility="Auto" Width="Auto" Grid.Row="1">
<Grid ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Visible">
<TextBlock x:Name="txtblSomeBlockValidated" Foreground="{StaticResource BlueTextBrush}" Height="42" HorizontalAlignment="Stretch" />
<TextBlock Text="Some Details:" FontWeight="Bold" HorizontalAlignment="Center"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".5*"/>
<ColumnDefinition Width=".5*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<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="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="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="Some1:" Grid.Row="0" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="1" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="2" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="3" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="4" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="5" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="6" Grid.Column="0" Margin="0,10,0,0"/>
<TextBlock Text="Some1:" Grid.Row="7" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="8" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="9" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="10" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="11" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="12" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="13" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="14" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="15" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="16" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="17" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="18" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="19" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="20" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="21" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="22" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="23" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="24" Grid.Column="0"/>
<TextBlock Text="Some1:" Grid.Row="25" Grid.Column="0"/>
<TextBlock Text="{Binding Some1}" Grid.Row="0" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="1" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="2" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="3" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="4" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="5" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="6" Grid.Column="1" Margin="0,10,0,0"/>
<TextBlock Text="{Binding Some1}" Grid.Row="7" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="8" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="9" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="10" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="11" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="12" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="13" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="14" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="15" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="16" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="17" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="18" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="19" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="20" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="21" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="22" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="23" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="24" Grid.Column="1"/>
<TextBlock Text="{Binding Some1}" Grid.Row="25" Grid.Column="1"/>
</Grid>
</Grid>
</ScrollViewer>
<StackPanel Orientation="Horizontal" Grid.Row="2" >
<Button x:Name="btnAcceptSuggested" Margin="0,0,10,0" IsTabStop="True"
TabIndex="5" Height="28" Width="132" Click="btnAcceptSuggested_Click">
<StackPanel Orientation="Horizontal">
<Image Name="imgAcceptSuggestion"
Source="pack://application:,,,/Common;component/Images/Some1.bmp" Margin="0,0,5,0"/>
<TextBlock Name="txtblAcceptSuggested">
<Underline>A</Underline>ccept Suggested
</TextBlock>
<AccessText Text="_A" Height="0" Width="0"/>
</StackPanel>
</Button>
<Button x:Name="btnValidateSome" Margin="0,0,10,0" IsTabStop="True"
TabIndex="5" Height="28" Width="132" Click="btnValidateSome_Click">
<StackPanel Orientation="Horizontal">
<Image Name="imgAcceptSuggestion1"
Source="pack://application:,,,/Common;component/Images/Some1.bmp" Margin="0,0,5,0"/>
<TextBlock Name="txtblValidateSome" Grid.Column="1">
Show me <Underline>M</Underline>ore
</TextBlock>
<AccessText Text="_M" Height="0" Width="0"/>
</StackPanel>
</Button>
<Button x:Name="btnUndo" Margin="0,0,10,0" IsTabStop="True" Visibility="Collapsed"
TabIndex="5" Height="28" Width="132" Click="btnUndo_Click">
<StackPanel Orientation="Horizontal">
<Image Name="imgAcceptSuggestion2"
Source="pack://application:,,,/Common;component/Images/Some1.bmp" Margin="0,0,5,0"/>
<TextBlock Name="txtblUndo" Grid.Column="1">
<Underline>U</Underline>ndo
</TextBlock>
<AccessText Text="_U" Height="0" Width="0"/>
</StackPanel>
</Button>
<Button x:Name="btnOverrideSuggested" Margin="0,0,10,0" IsTabStop="True"
TabIndex="5" Height="28" Width="140" ToolTip="Override suggested validated Some." Click="btnOverrideSuggested_Click">
<StackPanel Orientation="Horizontal">
<Image Name="imgAcceptSuggestion3"
Source="pack://application:,,,/Common;component/Images/Some1.bmp" Margin="0,0,5,0"/>
<TextBlock Name="txtblOverrideSuggested" Grid.Column="1">
<Underline>O</Underline>verride Suggested
</TextBlock>
<AccessText Text="_O" Height="0" Width="0"/>
</StackPanel>
</Button>
</StackPanel>
</Grid>
</Grid>
<Rectangle x:Name="rectRowBorder_Row05" Grid.Row="5" Style="{StaticResource ResourceKey=HorizontalRectangleBorderStyle}" />
<StackPanel Grid.Row="6" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,5,0,5">
<Button x:Name="btnCancel" Margin="0,0,10,0" IsTabStop="True"
TabIndex="5" Height="28" Width="132" IsCancel="True">
<StackPanel Orientation="Horizontal">
<Image Name="imgCancel"
Source="pack://application:,,,/Common;component/Images/Cancel.bmp" Margin="0,0,5,0"/>
<TextBlock Name="txtblCancel" Grid.Column="1">
<Underline>C</Underline>ancel
</TextBlock>
<AccessText Text="_C" Height="0" Width="0"/>
</StackPanel>
</Button>
</StackPanel>
</Grid>
</Window>
Sorry for the huge code, but that's what I have. Also, please leave a comment for downvotes.
Since I need to have a portion (but not all) of my page in a Scroll Viewer, I've got a winrt-xaml layout like so:
<Page>
<StackPanel>
<Grid>
</Grid>
<ScrollViewer>
<Grid>
</Grid>
</ScrollViewer>
</StackPanel>
</Page>
I have column titles for the second grid, which is inside the scroll viewer. If I put the column titles outside the grid (placing them in the last row of the outer grid) it is difficult if not impossible to make them align with the columns in the inner grid. But if I leave them in the inner grid (inside the ScrollViewer) they can scroll out of sight.
SO: is it possible to freeze that first row into place? Or, OTOH, is if, after all, readily doable to have the column widths in "Grid1" (the outer grid) align seamlessly with the column widths in "Grid2" (the inner grid)?
UPDATE
I can't see why, but it's not quite working, using option #2 in Juan's answer. The only problem is that both the "Longitude" and the "Color" labels are displayed way to the right of where they should be - all the others align perfectly, and their horizontal alignment property is set to "Left," so I don't see why these two are not cooperating. Here's the xaml:
Group Name
<TextBlock Foreground="Yellow" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="1" FontSize="28" VerticalAlignment="Center" HorizontalAlignment="Center">Title</TextBlock>
<TextBlock Foreground="Yellow" Grid.Row="2" Grid.Column="1" FontSize="28" VerticalAlignment="Center">Address</TextBlock>
<TextBlock Foreground="Yellow" Grid.Row="2" Grid.Column="3" FontSize="28" VerticalAlignment="Center" HorizontalAlignment="Left" >Latitude</TextBlock>
<TextBlock Foreground="Yellow" Grid.Row="2" Grid.Column="5" FontSize="28" VerticalAlignment="Center" HorizontalAlignment="Left">Longitude</TextBlock>
<TextBlock Foreground="Yellow" Grid.Row="2" Grid.Column="6" Grid.ColumnSpan="2" FontSize="28" VerticalAlignment="Center">Color</TextBlock>
</Grid>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<TextBlock x:Name="textBlockLocation1" FontSize="20" Margin="4" HorizontalAlignment="Right">Location 1</TextBlock>
<TextBox x:Name="textBoxTitle1" Margin="4" MinWidth="200"></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="1">
<TextBlock x:Name="textBlockLocation2" FontSize="20" Margin="4" HorizontalAlignment="Right">Location 2</TextBlock>
<TextBox x:Name="textBoxTitle2" Margin="4" Width="200"></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="2">
<TextBlock x:Name="textBlockLocation3" FontSize="20" Margin="4" HorizontalAlignment="Right">Location 3</TextBlock>
<TextBox x:Name="textBoxTitle3" Margin="4" Width="200"></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="3">
<TextBlock x:Name="textBlockLocation4" FontSize="20" Margin="4" HorizontalAlignment="Right">Location 4</TextBlock>
<TextBox x:Name="textBoxTitle4" Margin="4" Width="200"></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="4">
<TextBlock x:Name="textBlockLocation5" FontSize="20" Margin="4" HorizontalAlignment="Right">Location 5</TextBlock>
<TextBox x:Name="textBoxTitle5" Margin="4" Width="200"></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="5">
<TextBlock x:Name="textBlockLocation6" FontSize="20" Margin="4" HorizontalAlignment="Right">Location 6</TextBlock>
<TextBox x:Name="textBoxTitle6" Margin="4" Width="200"></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="6">
<TextBlock x:Name="textBlockLocation7" FontSize="20" Margin="4" HorizontalAlignment="Right">Location 7</TextBlock>
<TextBox x:Name="textBoxTitle7" Margin="4" Width="200"></TextBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="7">
<TextBlock x:Name="textBlockLocation8" FontSize="20" Margin="4" HorizontalAlignment="Right">Location 8</TextBlock>
<TextBox x:Name="textBoxTitle8" Margin="4" Width="200" LostFocus="CheckForAllRecordsValid" ></TextBox>
</StackPanel>
<TextBox x:Name="textBoxAddress1" Grid.Row="0" Grid.Column="1" MinWidth="240" Margin="4"></TextBox>
<TextBox x:Name="textBoxAddress2" Grid.Row="1" Grid.Column="1" Margin="4"></TextBox>
<TextBox x:Name="textBoxAddress3" Grid.Row="2" Grid.Column="1" Margin="4"></TextBox>
<TextBox x:Name="textBoxAddress4" Grid.Row="3" Grid.Column="1" Margin="4"></TextBox>
<TextBox x:Name="textBoxAddress5" Grid.Row="4" Grid.Column="1" Margin="4"></TextBox>
<TextBox x:Name="textBoxAddress6" Grid.Row="5" Grid.Column="1" Margin="4"></TextBox>
<TextBox x:Name="textBoxAddress7" Grid.Row="6" Grid.Column="1" Margin="4"></TextBox>
<TextBox x:Name="textBoxAddress8" Grid.Row="7" Grid.Column="1" Margin="4" LostFocus="CheckForAllRecordsValid" ></TextBox>
<TextBox x:Name="textBoxLatitude1" Grid.Row="0" Grid.Column="3" Margin="4" MinWidth="120"></TextBox>
<TextBox x:Name="textBoxLatitude2" Grid.Row="1" Grid.Column="3" Margin="4" ></TextBox>
<TextBox x:Name="textBoxLatitude3" Grid.Row="2" Grid.Column="3" Margin="4" ></TextBox>
<TextBox x:Name="textBoxLatitude4" Grid.Row="3" Grid.Column="3" Margin="4" ></TextBox>
<TextBox x:Name="textBoxLatitude5" Grid.Row="4" Grid.Column="3" Margin="4" ></TextBox>
<TextBox x:Name="textBoxLatitude6" Grid.Row="5" Grid.Column="3" Margin="4" ></TextBox>
<TextBox x:Name="textBoxLatitude7" Grid.Row="6" Grid.Column="3" Margin="4" ></TextBox>
<TextBox x:Name="textBoxLatitude8" Grid.Row="7" Grid.Column="3" Margin="4" LostFocus="CheckForAllRecordsValid" ></TextBox>
<TextBox x:Name="textBoxLongitude1" Grid.Row="0" Grid.Column="5" Margin="4" MinWidth="120"></TextBox>
<TextBox x:Name="textBoxLongitude2" Grid.Row="1" Grid.Column="5" Margin="4"></TextBox>
<TextBox x:Name="textBoxLongitude3" Grid.Row="2" Grid.Column="5" Margin="4"></TextBox>
<TextBox x:Name="textBoxLongitude4" Grid.Row="3" Grid.Column="5" Margin="4"></TextBox>
<TextBox x:Name="textBoxLongitude5" Grid.Row="4" Grid.Column="5" Margin="4"></TextBox>
<TextBox x:Name="textBoxLongitude6" Grid.Row="5" Grid.Column="5" Margin="4"></TextBox>
<TextBox x:Name="textBoxLongitude7" Grid.Row="6" Grid.Column="5" Margin="4"></TextBox>
<TextBox x:Name="textBoxLongitude8" Grid.Row="7" Grid.Column="5" Margin="4" LostFocus="CheckForAllRecordsValid"></TextBox>
<ComboBox x:Name="cmbxColor1" Grid.Row="0" Grid.Column="6" Margin="4,4,0,4" MinWidth="200" Height="36" HorizontalAlignment="Left" SelectionChanged="CmbxColor1_OnSelectionChanged"/>
<ComboBox x:Name="cmbxColor2" Grid.Row="1" Grid.Column="6" Margin="4,4,0,4" MinWidth="200" Height="36" HorizontalAlignment="Left"/>
<ComboBox x:Name="cmbxColor3" Grid.Row="2" Grid.Column="6" Margin="4,4,0,4" MinWidth="200" Height="36" HorizontalAlignment="Left"/>
<ComboBox x:Name="cmbxColor4" Grid.Row="3" Grid.Column="6" Margin="4,4,0,4" MinWidth="200" Height="36" HorizontalAlignment="Left"/>
<ComboBox x:Name="cmbxColor5" Grid.Row="4" Grid.Column="6" Margin="4,4,0,4" MinWidth="200" Height="36" HorizontalAlignment="Left"/>
<ComboBox x:Name="cmbxColor6" Grid.Row="5" Grid.Column="6" Margin="4,4,0,4" MinWidth="200" Height="36" HorizontalAlignment="Left"/>
<ComboBox x:Name="cmbxColor7" Grid.Row="6" Grid.Column="6" Margin="4,4,0,4" MinWidth="200" Height="36" HorizontalAlignment="Left"/>
<ComboBox x:Name="cmbxColor8" Grid.Row="7" Grid.Column="6" Margin="4,4,0,4" MinWidth="200" Height="36" HorizontalAlignment="Left" LostFocus="CheckForAllRecordsValid" />
<TextBlock Grid.Row="0" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="7,10,6,10" >or</TextBlock>
<TextBlock Grid.Row="1" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="7,10,6,10">or</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="7,10,6,10">or</TextBlock>
<TextBlock Grid.Row="3" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="7,10,6,10">or</TextBlock>
<TextBlock Grid.Row="4" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="7,10,6,10">or</TextBlock>
<TextBlock Grid.Row="5" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="7,10,6,10">or</TextBlock>
<TextBlock Grid.Row="6" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="7,10,6,10">or</TextBlock>
<TextBlock Grid.Row="7" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="7,10,6,10">or</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="6,10">and</TextBlock>
<TextBlock Grid.Row="1" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="6,10">and</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="6,10">and</TextBlock>
<TextBlock Grid.Row="3" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="6,10">and</TextBlock>
<TextBlock Grid.Row="4" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="6,10">and</TextBlock>
<TextBlock Grid.Row="5" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="6,10">and</TextBlock>
<TextBlock Grid.Row="6" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="6,10">and</TextBlock>
<TextBlock Grid.Row="7" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" Margin="6,10">and</TextBlock>
</Grid>
</ScrollViewer>
UPDATE 2
Since I'm still having an alignment problem (the grid columns above don't always align, width-wise, with the grid columns below), I'm posting here, as requested, my Grid XAML. First, the top grid:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="320"></ColumnDefinition>
<ColumnDefinition Width="{Binding ElementName=Col1Grid2, Path=ActualWidth}"></ColumnDefinition>
<ColumnDefinition Width="{Binding ElementName=Col2Grid2, Path=ActualWidth}"></ColumnDefinition>
<ColumnDefinition Width="{Binding ElementName=Col3Grid2, Path=ActualWidth}"></ColumnDefinition>
<ColumnDefinition Width="{Binding ElementName=Col4Grid2, Path=ActualWidth}"></ColumnDefinition>
<ColumnDefinition Width="{Binding ElementName=Col5Grid2, Path=ActualWidth}"></ColumnDefinition>
<ColumnDefinition Width="{Binding ElementName=Col6Grid2, Path=ActualWidth}"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="120"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
...now, the second (inner) grid:
<Grid x:Name="gridDynamicRowsParent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="320"></ColumnDefinition>
<ColumnDefinition x:Name="Col1Grid2" Width="Auto"></ColumnDefinition>
<ColumnDefinition x:Name="Col2Grid2" Width="Auto" />
<ColumnDefinition x:Name="Col3Grid2" Width="Auto"></ColumnDefinition>
<ColumnDefinition x:Name="Col4Grid2" Width="Auto"></ColumnDefinition>
<ColumnDefinition x:Name="Col5Grid2" Width="Auto"></ColumnDefinition>
<ColumnDefinition x:Name="Col6Grid2" Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
Also, the controls are "rubbery" - when I enter a value for which they are not wide enough, they will expand sideways to accommodate some of the additional space; I don't want this - the controls (TextBoxes) should remain the same width...
You can try two different approaches for your case:
Create a SharedSizeGroup for the columns (see this article -one between a lot out there- as example )
Name the columns in the second grid and set the columns in the first grid to bind their Width to the ActualWidth property of the corresponding columns, something like this:
<Page>
<StackPanel>
<Grid Name="Grid1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ElementName=Col1Grid2, Path=ActualWidth}"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ScrollViewer>
<Grid Name="Grid2">
<Grid.ColumnDefinitions>
<ColumnDefinition Name="Col1Grid2" Width="*"/>
<ColumnDefinition Name="Col2Grid2" Width="Auto"/>
</Grid.ColumnDefinitions>
</ScrollViewer>
</StackPanel>
</Page>
See if you can get the desired behavior with any of these options. Good luck!