C# WPF Scrollbar changes/moves content - c#

I'm having a hard time making my WPF form scrollable. The form is quite long, and i want the user to be able to scroll further down. If i adjust the height of the form, as the scrollbar becomes active, it moves everything around, and makes my content smaller. How do i avoid this? I've added 2 Pictures (Before & After) and my XAML code.
<Window x:Class="RegisterForm.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="1000" Width="700" MinHeight="1000" MinWidth="700">
<ScrollViewer
VerticalScrollBarVisibility="Visible"
CanContentScroll="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label
Content="Full Name"
FontSize="14"
FontWeight="Bold"
Grid.Row="1"
Grid.ColumnSpan="3"
Margin="40,0,40,0"
HorizontalContentAlignment="Left">
</Label>
<Label
Content="Gender"
FontSize="14"
FontWeight="Bold"
Grid.Row="2"
Grid.ColumnSpan="3"
Margin="40,0,40,0"
HorizontalContentAlignment="Left">
</Label>
<Label
Content="Date of Birth"
FontSize="14"
FontWeight="Bold"
Grid.Row="3"
Grid.ColumnSpan="3"
Margin="40,0,40,0"
HorizontalContentAlignment="Left">
</Label>
<Label
Content="Address"
FontSize="14"
FontWeight="Bold"
Grid.Row="4"
Grid.ColumnSpan="3"
Margin="40,0,40,0"
HorizontalContentAlignment="Left">
</Label>
<Label
Content="Phone Number"
FontSize="14"
FontWeight="Bold"
Grid.Row="7"
Grid.ColumnSpan="3"
Margin="40,0,40,0"
HorizontalContentAlignment="Left">
</Label>
<Label
Content="Phone Number Family"
FontSize="14"
FontWeight="Bold"
Grid.Row="8"
Grid.ColumnSpan="3"
Margin="40,0,0,0"
HorizontalContentAlignment="Left">
</Label>
<Label
Content="E-mail"
FontSize="14"
FontWeight="Bold"
Grid.Row="9"
Grid.ColumnSpan="3"
Margin="40,0,40,0"
HorizontalContentAlignment="Left">
</Label>
<Label
Content="Do you speak english?"
FontSize="14"
FontWeight="Bold"
Grid.Row="10"
Grid.ColumnSpan="3"
Margin="40,0,0,0"
HorizontalContentAlignment="Left">
</Label>
<Label
Content="Education"
FontSize="14"
FontWeight="Bold"
Grid.Row="11"
Grid.ColumnSpan="3"
Margin="40,0,40,0"
HorizontalContentAlignment="Left">
</Label>
<Label
Content="Job Type/Profession"
FontSize="14"
FontWeight="Bold"
Grid.Row="12"
Grid.ColumnSpan="3"
Margin="40,0,0,0"
HorizontalContentAlignment="Left">
</Label>
<Label
Content="Experience"
FontSize="14"
FontWeight="Bold"
Grid.Row="13"
Grid.ColumnSpan="3"
Margin="40,0,40,0"
HorizontalContentAlignment="Left">
</Label>
<Label
Content="Drivers License"
FontSize="14"
FontWeight="Bold"
Grid.Row="14"
Grid.ColumnSpan="3"
Margin="40,0,40,0"
HorizontalContentAlignment="Left">
</Label>
<TextBox
x:Name="txtFirstName"
FontSize="14"
Grid.Row="1"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,0,0,30"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
</TextBox>
<Label
Content="First Name"
FontSize="12"
Grid.Row="1"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
<TextBox
x:Name="txtLastName"
FontSize="14"
Grid.Row="1"
Grid.Column="5"
Grid.ColumnSpan="3"
Margin="10,0,0,30"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
</TextBox>
<Label
Content="Last Name"
FontSize="12"
Grid.Row="1"
Grid.Column="5"
Grid.ColumnSpan="2"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
<ComboBox
x:Name="CBGender"
FontSize="12"
Grid.Row="2"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,0,0,30"
IsEditable="True"
IsReadOnly="True"
Text="Please Select"
FontStyle="Normal">
<ListBoxItem Content="Male" FontStyle="Normal"/>
<ListBoxItem Content="Female" FontStyle="Normal"/>
</ComboBox>
<ComboBox
x:Name="CBDOBDay"
FontSize="12"
Grid.Row="3"
Grid.Column="3"
Grid.ColumnSpan="1"
Margin="10,0,0,30"
IsEditable="True"
IsReadOnly="True"
Text="DD"
FontStyle="Normal">
</ComboBox>
<ComboBox
x:Name="CBDOBMonth"
FontSize="12"
Grid.Row="3"
Grid.Column="4"
Grid.ColumnSpan="1"
Margin="10,0,0,30"
IsEditable="True"
IsReadOnly="True"
Text="MM"
FontStyle="Normal">
</ComboBox>
<ComboBox
x:Name="CBDOBYear"
FontSize="12"
Grid.Row="3"
Grid.Column="5"
Grid.ColumnSpan="1"
Margin="10,0,0,30"
IsEditable="True"
IsReadOnly="True"
Text="YY"
FontStyle="Normal">
</ComboBox>
<TextBox
x:Name="txtStreetAddress"
FontSize="14"
Grid.Row="4"
Grid.Column="3"
Grid.ColumnSpan="3"
Margin="10,0,0,30"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
</TextBox>
<Label
Content="Street Address"
FontSize="12"
Grid.Row="4"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
<TextBox
x:Name="txtCity"
FontSize="14"
Grid.Row="5"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,0,0,30"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
</TextBox>
<Label
Content="City"
FontSize="12"
Grid.Row="5"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
<TextBox
x:Name="txtStateProvince"
FontSize="14"
Grid.Row="5"
Grid.Column="5"
Grid.ColumnSpan="3"
Margin="10,0,0,30"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
</TextBox>
<Label
Content="State / province"
FontSize="12"
Grid.Row="5"
Grid.Column="5"
Grid.ColumnSpan="2"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
<TextBox
x:Name="txtPostalZipCode"
FontSize="14"
Grid.Row="6"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,0,0,30"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
</TextBox>
<Label
Content="Postal / Zip code"
FontSize="12"
Grid.Row="6"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
<ComboBox
x:Name="CBCountry"
FontSize="12"
Grid.Row="6"
Grid.Column="5"
Grid.ColumnSpan="3"
Margin="10,0,0,30"
IsEditable="True"
IsReadOnly="True"
Text="Please Select"
FontStyle="Normal" SelectionChanged="CBCountry_SelectionChanged">
</ComboBox>
<Label
Content="Country"
FontSize="12"
Grid.Row="6"
Grid.Column="5"
Grid.ColumnSpan="2"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
<TextBox
x:Name="txtPhone1AreaCode"
FontSize="14"
Grid.Row="7"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,0,0,30"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
</TextBox>
<TextBox
x:Name="txtPhone1"
FontSize="14"
Grid.Row="7"
Grid.Column="5"
Grid.ColumnSpan="3"
Margin="10,0,0,30"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
</TextBox>
<Label
Content="Area Code (ex. +45)"
FontSize="12"
Grid.Row="7"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
<Label
Content="Phone Number"
FontSize="12"
Grid.Row="7"
Grid.Column="5"
Grid.ColumnSpan="2"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
<TextBox
x:Name="txtPhone2AreaCode"
FontSize="14"
Grid.Row="8"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,0,0,30"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
</TextBox>
<TextBox
x:Name="txtPhone2"
FontSize="14"
Grid.Row="8"
Grid.Column="5"
Grid.ColumnSpan="3"
Margin="10,0,0,30"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
</TextBox>
<Label
Content="Area Code (ex. +45)"
FontSize="12"
Grid.Row="8"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
<Label
Content="Phone Number"
FontSize="12"
Grid.Row="8"
Grid.Column="5"
Grid.ColumnSpan="2"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
<TextBox
x:Name="txtEmail"
FontSize="14"
Grid.Row="9"
Grid.Column="3"
Grid.ColumnSpan="4"
Margin="10,0,0,30"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
</TextBox>
<Label
Content="Ex. myname#example.com"
FontSize="12"
Grid.Row="9"
Grid.Column="3"
Grid.ColumnSpan="3"
Margin="10,25,0,0"
FontStyle="Italic"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left">
</Label>
</Grid>
</ScrollViewer>
//Thanks, Rasmus

The problem with ScrollViewer is that it is virtually infinite. So, the content inside it can't calculate relative sizes such as *. In your case, i think if you add a height to your grid, something like <Grid Height="1000"> it will work fine.

You have to specify the Heigh or MinHeigh of at least one part: The Editors (Labels / Textboxes / Comboboxes) or the GridRows or the whole Grid. Currrently the Grid is filled within the Window and the Columns also fill all together the whole Grid. Normally you would Set Grids' Rows Height to
<RowDefinition Height="auto" />
instead of
<RowDefinition Height="*" />
and give the editors some kind of MinHeight or Padding.
So there are many Solutions. It just depends on how you want to have the Labels/Editors Height. (Dynamic or fixed)
EDIT/ADD:
And just as a SideNote, if you define the same style foreach of those Row-/ and ColumnDefinitions, you maybe should assign a Style in the Grid for those.
It makes things easier to Change at once ;D
<Grid>
<Grid.Resources>
<Style TargetType="RowDefinition">
<Setter Property="Height" Value="auto" />
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<!-- ... -->
</Grid>

Related

Scrollviewer to a postion of a control by code - wpf c#

I am developing a small application when i need to scroll by code to a postion of a GroupBox Control, the part of my xaml files that contains the scrollviewer is the following one (I have a scrollviewer, inside a stackpanel and inside of that the GroupBox):
<ScrollViewer x:Name="scrollViewer" Grid.Row="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">
<StackPanel x:Name="stackPanel" VerticalAlignment="Stretch" Margin="0,16,0,0">
<GroupBox x:Name="groupBox">
<GroupBox.Header>
<TextBlock Text="Desbloquear" FontWeight="Bold"/>
</GroupBox.Header>
<StackPanel Margin="0" Orientation="Vertical" Height="155" HorizontalAlignment="Stretch" VerticalAlignment="Top" Background="LightBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Label Content="Usuario:" Grid.Row="0" Grid.Column="0" Margin="0,2,0,2"/>
<ComboBox x:Name="comboBoxUnblockUser" IsReadOnly="true" Margin="4,4,4,4" Grid.Row="0" Grid.Column="1"/>
<Label Content="Caja:" Margin="0,2,0,2" Grid.Row="1" Grid.Column="0"/>
<ComboBox x:Name="comboBoxUnblockCashMachine" Margin="4,4,4,4" IsReadOnly="true" Grid.Row="1" Grid.Column="1"/>
<Label Content="Estatus de solicitud:" Margin="0,2,0,2" Grid.Row="2" Grid.Column="0"/>
<Label x:Name="labelStatusUnblock" Margin="0,2,0,2" Content="----------" FontWeight="Bold" Grid.Row="2" Grid.Column="1"/>
<Label Content="Mensaje de Soporte:" Margin="0,2,0,2" Grid.Row="3" Grid.Column="0"/>
<Label x:Name="labelMessageUnblock" Margin="0,2,0,2" Content="----------" FontWeight="Bold" Grid.Row="3" Grid.Column="1"/>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<Button x:Name="buttonSolicitudeUnblock" Content="Solicitar" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Top" Width="75" Height="30" ToolTip="Entrar a la aplicación"
Background="WhiteSmoke"
Foreground="Black"
FontFamily="Arial"
FontWeight="Bold" Click="buttonSolicitudeUnblock_Click"/>
<Button x:Name="buttonExecuteUnblock" Content="Ejecutar" IsEnabled="false" HorizontalAlignment="Left" Margin="90,0,0,0" VerticalAlignment="Top" Width="75" Height="30" ToolTip="Entrar a la aplicación"
Background="WhiteSmoke"
Foreground="Black"
FontFamily="Arial"
FontWeight="Bold"/>
</Grid>
</StackPanel>
</GroupBox>
<GroupBox x:Name="groupBox2">
<GroupBox.Header>
<TextBlock Text="Desbloquear caja Impresora Fiscal" FontWeight="Bold"/>
</GroupBox.Header>
<StackPanel Margin="0" Orientation="Vertical" Height="125" HorizontalAlignment="Stretch" VerticalAlignment="Top" Background="White">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Label Content="Caja:" Grid.Row="0" Grid.Column="0" Margin="0,2,0,2"/>
<ComboBox x:Name="comboBoxUnblockFiscalMachine" IsReadOnly="true" Margin="4,4,4,4" Grid.Row="0" Grid.Column="1"/>
<Label Content="Estatus de solicitud:" Margin="0,2,0,2" Grid.Row="1" Grid.Column="0"/>
<Label x:Name="labelStatusUnblockFiscalMachine" Margin="0,2,0,2" Content="----------" FontWeight="Bold" Grid.Row="1" Grid.Column="1"/>
<Label Content="Mensaje de Soporte:" Margin="0,2,0,2" Grid.Row="2" Grid.Column="0"/>
<Label x:Name="labelMessageUnblockFiscalMachine" Margin="0,2,0,2" Content="----------" FontWeight="Bold" Grid.Row="2" Grid.Column="1"/>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<Button x:Name="buttonSolicitudeUnblockFiscalMachine" Content="Solicitar" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Top" Width="75" Height="30" ToolTip="Entrar a la aplicación"
Background="WhiteSmoke"
Foreground="Black"
FontFamily="Arial"
FontWeight="Bold"/>
<Button x:Name="buttonExecuteUnblockFiscalMachine" Content="Ejecutar" IsEnabled="false" HorizontalAlignment="Left" Margin="90,0,0,0" VerticalAlignment="Top" Width="75" Height="30" ToolTip="Entrar a la aplicación"
Background="WhiteSmoke"
Foreground="Black"
FontFamily="Arial"
FontWeight="Bold"/>
</Grid>
</StackPanel>
</GroupBox>
<GroupBox x:Name="groupBox3">
<GroupBox.Header>
<TextBlock Text="Reenvio de Cierre" FontWeight="Bold"/>
</GroupBox.Header>
<StackPanel Margin="0" Orientation="Vertical" Height="125" HorizontalAlignment="Stretch" VerticalAlignment="Top" Background="LightBlue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Label Content="Fecha:" Grid.Row="0" Grid.Column="0" Margin="0,2,0,2"/>
<DatePicker x:Name="datePickerResendCloser" Margin="4,4,4,4" Grid.Row="0" Grid.Column="1" SelectedDate="{x:Static sys:DateTime.Now}" Focusable="False"/>
<Label Content="Estatus de solicitud:" Margin="0,2,0,2" Grid.Row="1" Grid.Column="0"/>
<Label x:Name="labelStatusResendCloser" Margin="0,2,0,2" Content="----------" FontWeight="Bold" Grid.Row="1" Grid.Column="1"/>
<Label Content="Mensaje de Soporte:" Margin="0,2,0,2" Grid.Row="2" Grid.Column="0"/>
<Label x:Name="labelMessageResendCloser" Margin="0,2,0,2" Content="----------" FontWeight="Bold" Grid.Row="2" Grid.Column="1"/>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<Button x:Name="buttonSolicitudeResendCloser" Content="Solicitar" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Top" Width="75" Height="30" ToolTip="Entrar a la aplicación"
Background="WhiteSmoke"
Foreground="Black"
FontFamily="Arial"
FontWeight="Bold"/>
<Button x:Name="buttonExecuteResendCloser" Content="Ejecutar" IsEnabled="false" HorizontalAlignment="Left" Margin="90,0,0,0" VerticalAlignment="Top" Width="75" Height="30" ToolTip="Entrar a la aplicación"
Background="WhiteSmoke"
Foreground="Black"
FontFamily="Arial"
FontWeight="Bold"/>
</Grid>
</StackPanel>
</GroupBox>
<GroupBox x:Name="groupBox4">
<GroupBox.Header>
<TextBlock Text="Cerrar caja (cuando se asignó mas no se usó)" FontWeight="Bold"/>
</GroupBox.Header>
<StackPanel Margin="0" Orientation="Vertical" Height="155" HorizontalAlignment="Stretch" VerticalAlignment="Top" Background="White">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Label Content="Caja:" Grid.Row="0" Grid.Column="0" Margin="0,2,0,2"/>
<ComboBox x:Name="comboBoxCloseCashMachine" IsReadOnly="true" Margin="4,4,4,4" Grid.Row="0" Grid.Column="1"/>
<Label Content="Fecha:" Grid.Row="1" Grid.Column="0" Margin="0,2,0,2"/>
<DatePicker x:Name="datePickerCloseCashMachine" Margin="4,4,4,4" Grid.Row="1" Grid.Column="1" SelectedDate="{x:Static sys:DateTime.Now}" Focusable="False"/>
<Label Content="Estatus de solicitud:" Margin="0,2,0,2" Grid.Row="2" Grid.Column="0"/>
<Label x:Name="labelStatusCloseCashMachine" Margin="0,2,0,2" Content="----------" FontWeight="Bold" Grid.Row="2" Grid.Column="1"/>
<Label Content="Mensaje de Soporte:" Margin="0,2,0,2" Grid.Row="3" Grid.Column="0"/>
<Label x:Name="labelMessageCloseCashMachine" Margin="0,2,0,2" Content="----------" FontWeight="Bold" Grid.Row="3" Grid.Column="1"/>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<Button x:Name="buttonSolicitudeCloseCashMachine" Content="Solicitar" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Top" Width="75" Height="30" ToolTip="Entrar a la aplicación"
Background="WhiteSmoke"
Foreground="Black"
FontFamily="Arial"
FontWeight="Bold"/>
<Button x:Name="buttonExecuteCloseCashMachine" Content="Ejecutar" IsEnabled="false" HorizontalAlignment="Left" Margin="90,0,0,0" VerticalAlignment="Top" Width="75" Height="30" ToolTip="Entrar a la aplicación"
Background="WhiteSmoke"
Foreground="Black"
FontFamily="Arial"
FontWeight="Bold"/>
</Grid>
</StackPanel>
</GroupBox>
</StackPanel>
</ScrollViewer>
I have tried other solutions in stackoverflow but i can't figure out why i can not handled it to work.
I just have the declaration of the function
private void ScrollToGroupBox(System.Windows.Controls.GroupBox groupBox)
{
//I NEED TO GET THE POSITION OF THE GRUOPBOX INSIDE OF THE SCROLLVIEWER
scrollViewer.ScrollToVerticalOffset(0);
}
private void ScrollToGroupBox(System.Windows.Controls.GroupBox groupBox)
{
groupBox.BringIntoView();
}

How to Stop WPF TextBox from growing

WPF TextBox Control grows when a long text has been typed in.
This question has been already raised in Stackoverflow
and I refereed few answers also, but still I didn't find the proper answer which is working.
Here same problem has been mentioned but no working solution for this kind of issue.
I have spend enough time to solve this, please help me to solve this issue.
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<DockPanel LastChildFill="False" Grid.IsSharedSizeScope="True">
<GroupBox DockPanel.Dock="Top" DataContext="{Binding Data, ValidatesOnNotifyDataErrors=False}">
<GroupBox.HeaderTemplate>
<DataTemplate>
<TextBlock shell:Localization.VbeiTag="vbeiGeneralInformation" Text="General Information"/>
</DataTemplate>
</GroupBox.HeaderTemplate>
<Grid DockPanel.Dock="Top" Margin="0,0,0,3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="GroupA" />
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="Auto" SharedSizeGroup="GroupB" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<!--Code Prefix Label -->
<Label Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" Content="Code" ></Label>
<Label Grid.Row="0" Grid.Column="2" HorizontalAlignment="Left" Content="Name" ></Label>
<Label Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" Content="Title" ></Label>
<Label Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" Content="Long Reference" ></Label>
<Label Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" Content="Client Reference"></Label>
<Label Grid.Row="3" Grid.Column="2" HorizontalAlignment="Left" Content="Lead Sub-Business Unit" ></Label>
<!--Code Prefix Editor-->
<common:StudyCodeEditor Grid.Row="0" Grid.Column="1" DataContext="{Binding ValidatesOnNotifyDataErrors=False}"
SuggestedStudyCodePrefixRange="{ViewModelBinding SuggestedStudyCodePrefixRange}"/>
<!--Study Name-->
<TextBox Grid.Row="0" Grid.Column="3" Margin="3" VerticalAlignment="Top"
Text="{Binding StudyName, UpdateSourceTrigger=PropertyChanged}" />
<!--Study Title -->
<TextBox Grid.Row="1" Grid.Column="1" Margin="3" Grid.ColumnSpan="3" VerticalAlignment="Top"
Text="{Binding StudyOfficialTitle, UpdateSourceTrigger=PropertyChanged}" />
<!--Client Long Reference -->
<TextBox Grid.Row="2" Grid.Column="1" Margin="3" Grid.ColumnSpan="3" VerticalAlignment="Top"
Text="{Binding StudyClientLongReference, UpdateSourceTrigger=PropertyChanged}" />
<!--Client Study Reference-->
<TextBox Grid.Row="3" Grid.Column="1" Margin="3" VerticalAlignment="Top"
Text="{Binding ClientStudyReference, UpdateSourceTrigger=PropertyChanged}" />
<!-- Description -->
<TextBox Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="3"
Text="{Binding Description}" AcceptsReturn="True" DockPanel.Dock="Top"
TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" Margin="3" Height="62"/>
</Grid>
</GroupBox>
</DockPanel>
</ScrollViewer>
MaxWidth should do the trick. If not, what went wrong in your case?

Print a usercontrol to the center of an A4 page

I have a user control which I need to print.
The form is just a basic filled out form. I have the controls all placed in a stackpanel which is named and the button for printing is outside the stackpanel, so the button is not printed with.
<UserControl x:Class="*****.PrintInitiateRequestFormView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:WpfToolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
mc:Ignorable="d"
Style="{StaticResource TransitionAnimation}">
<ScrollViewer>
<Border Style="{StaticResource PanelWindowBackground}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel x:Name="PrntFrm"
Grid.Row="0">
<Border Grid.Row="1"
Grid.Column="1"
Margin="3,3,3,0"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Style="{StaticResource PanelWindowBackground}">
<Grid>
<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="Auto" />
<RowDefinition Height="Auto" />
<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" />
<ColumnDefinition Width="200" />
<ColumnDefinition Width="200" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Source="/Lamacs_8;component/Resources/Images/NMBM_Logo.jpg"
Stretch="Fill"
Grid.ColumnSpan="2"
Margin="0,0,74,0"
Width="265">
</Image>
<Label Grid.Row="1"
Grid.ColumnSpan="4"
HorizontalAlignment="Center"
Content="WORK REQUEST"
FontSize="20" />
<Label Grid.Row="2"
Grid.ColumnSpan="2"
Content="Call Centre"
FontSize="20">
</Label>
<Label Grid.Row="2"
Grid.Column="2"
FontSize="20"
Content="Reference Number:" />
<Label Grid.Row="2"
Grid.Column="3"
FontSize="16"
Content="{Binding RefNo}" />
<Label Grid.Row="3"
Grid.Column="2"
FontSize="16"
Content="Date & Time Logged:" />
<Label Grid.Column="3"
Grid.Row="3"
FontSize="16"
Content="{Binding CaptureDate}" />
<Label Grid.Row="4"
Grid.Column="0"
Content="Building:"
FontSize="16" />
<Label Grid.Row="4"
Grid.Column="1"
Content="{Binding LandObjectBuilding}"
FontSize="16" />
<Label Grid.Row="5"
Grid.Column="0"
Content="Address:"
FontSize="16" />
<Label Grid.Column="1"
Grid.Row="5"
FontSize="16"
Grid.ColumnSpan="2"
Content="{Binding LandObjectAddress}" />
<Label Grid.Row="6"
Grid.Column="0"
Content="Caller:"
FontSize="16" />
<Label Grid.Row="6"
Grid.Column="1"
Content="{Binding CallerName}"
FontSize="16" />
<Label Grid.Row="6"
Grid.Column="2"
Content="Telephone:"
FontSize="16" />
<Label Grid.Row="6"
Grid.Column="3"
Content="{Binding CallerTel}"
FontSize="16" />
<Label Grid.Row="7"
Grid.Column="0"
Content="Problem Description:"
FontSize="16" />
<TextBox Grid.Row="7"
Grid.Column="1"
Grid.ColumnSpan="3"
Height="50"
TextWrapping="Wrap"
Text="{Binding ProblemDesc}"
FontSize="16"
Background="Transparent"
BorderBrush="Transparent" />
<Label Grid.Row="8"
Grid.Column="2"
Content="Person Responsible:"
FontSize="16" />
<Label Grid.Row="8"
Grid.Column="3"
Content="{Binding Assistant}"
FontSize="16" />
<Label Grid.Row="8"
Grid.Column="0"
Content="Sector"
FontSize="16" />
<Label Grid.Row="8"
Grid.Column="1"
Content="{Binding Sector}"
FontSize="16" />
<Label Grid.Row="9"
Grid.Column="0"
Content="Component"
FontSize="16" />
<Label Grid.Row="9"
Grid.Column="1"
Content="{Binding Component}"
FontSize="16" />
<Label Grid.Row="9"
Grid.Column="2"
Content="Element"
FontSize="16" />
<Label Grid.Row="9"
Grid.Column="3"
Content="{Binding Element}"
FontSize="16" />
<Separator Grid.Row="11"
Grid.ColumnSpan="4" />
<Label Grid.Row="12"
Grid.Column="0"
Content="Official:"
FontSize="20" />
<Label Grid.Row="13"
Grid.Column="0"
Content="Scope Of Work:"
FontSize="16" />
<TextBox Grid.Row="13"
Grid.Column="1"
Grid.ColumnSpan="3"
FontSize="16"
TextWrapping="Wrap"
Text="{Binding ScopeOfWork}"
Background="Transparent"
BorderBrush="Transparent" />
<Label Grid.Row="14"
Grid.Column="0"
Content="Cost Estimate:"
FontSize="16" />
<Label Grid.Row="14"
Grid.Column="1"
FontSize="16"
Content="{Binding CostEstimate}" />
<Label Grid.Row="14"
Grid.Column="2"
Content="Name:"
FontSize="16" />
<Label Grid.Row="14"
Grid.Column="3"
FontSize="16"
Content="{Binding ReportName}" />
<Label FontSize="16"
Grid.Row="15"
Grid.Column="0"
Content="Date:" />
<Label Grid.Row="15"
Grid.Column="1"
Content="{Binding FormDate}"
FontSize="16" />
<Label Grid.Row="16"
Grid.Column="0"
Grid.ColumnSpan="4"
Content="(Obtain Quotes if required)"
FontSize="16"
HorizontalAlignment="Center" />
<Separator Grid.Row="17"
Grid.ColumnSpan="4" />
<Label FontSize="20"
Content="Admin"
Grid.Column="0"
Grid.Row="18" />
<Label FontSize="16"
Content="Funds Available:"
Grid.Column="0"
Grid.Row="19" />
<Label FontSize="16"
Content="Yes"
Grid.Column="1"
Grid.Row="19" />
<Label FontSize="16"
Content="No"
Grid.Column="1"
Grid.Row="19"
Margin="50,0,0,0" />
<Label Grid.Column="2"
Grid.Row="19"
Content="Vote/ISO Number:"
FontSize="16" />
<Label Grid.Row="19"
Grid.Column="3"
FontSize="16"
Content="{Binding VISONum}" />
<Separator Grid.ColumnSpan="4"
Grid.Row="20" />
<Label Grid.Row="21"
Grid.Column="0"
Content="Official:"
FontSize="20" />
<Label Grid.Row="22"
Grid.Column="0"
Content="Contractor:"
FontSize="16" />
<Label Grid.Row="22"
Grid.Column="1"
Grid.ColumnSpan="2"
FontSize="16"
Content="{Binding Contractor}" />
<Label Grid.Row="23"
Grid.Column="0"
Content="Order No:"
FontSize="16" />
<Label Grid.Row="23"
Grid.Column="1"
FontSize="16"
Content="{Binding OrderNo}" />
<Label Grid.Row="23"
Grid.Column="2"
Content="Date Issued:"
FontSize="16" />
<Label Grid.Row="23"
Grid.Column="3"
Content="{Binding DateIssued}"
FontSize="16" />
<Label Grid.Column="0"
Grid.Row="24"
FontSize="16"
Content="Cost of Works:" />
<Label Grid.Row="24"
Grid.Column="1"
FontSize="16"
Content="{Binding CostWorks}" />
<Label Content="Variance:"
FontSize="16"
Grid.Row="24"
Grid.Column="2" />
<Label Grid.Row="24"
Grid.Column="3"
FontSize="16"
Content="{Binding Variance}" />
<Label Grid.Column="0"
Grid.Row="25"
FontSize="16"
Content="Reason:" />
<Label Grid.Row="25"
Grid.Column="1"
Grid.ColumnSpan="3"
FontSize="16"
Content="{Binding Reason}" />
<Separator Grid.ColumnSpan="4"
Grid.Row="26" />
<Label Grid.Row="27"
Grid.Column="0"
Grid.ColumnSpan="3"
Content="I hereby declare that the cost of the works is fair and reasonable."
FontSize="16" />
<Label Grid.Row="28"
Grid.Column="0"
Content="Name:"
FontSize="16" />
<Label Grid.Row="28"
Grid.Column="1"
Grid.ColumnSpan="3"
VerticalContentAlignment="Bottom"
FontSize="16"
Height="40"
Content="......................................................................................................................" />
<Label Grid.Row="29"
Grid.Column="0"
Content="Date:"
FontSize="16" />
<Label Grid.Row="29"
Grid.Column="1"
Grid.ColumnSpan="3"
VerticalContentAlignment="Bottom"
FontSize="16"
Height="40"
Content="......................................................................................................................" />
<Label Grid.Row="30"
Grid.Column="0"
Content="Signature:"
FontSize="16" />
<Label Grid.Row="30"
Grid.Column="1"
Grid.ColumnSpan="3"
VerticalContentAlignment="Bottom"
FontSize="16"
Height="40"
Content="......................................................................................................................" />
</Grid>
</Border>
</StackPanel>
<StackPanel Grid.Row="1"
Orientation="Horizontal">
<Button Width="150"
Height="25"
Margin="4,0,0,5"
HorizontalAlignment="Left"
Template="{StaticResource PrintButtonTemplate}"
Click="Button_Click" />
<Button Width="150"
Height="25"
Margin="4,0,0,5"
HorizontalAlignment="Left"
Template="{StaticResource CloseButtonTemplate}"
x:Name="CloseButton"
Click="CloseButton_Click" />
</StackPanel>
</Grid>
</Border>
</ScrollViewer>
You can mind all the MVVM loading, that is done sepratly.
Anyway, using code behind, I basically add this to my button click:
PrintDialog prnt = new PrintDialog();
prnt.PrintVisual(PrntFrm, "Initiate Work Request");
This prints out my form (stackpanel), but it is not exactly centered on the page. It sits at the top left, and some of the text is cut off on the left side.
Using the PrintDialog methods, how does one set the size of the page to be printed, or just center the contents of the printable form? And also, how can I set the page orientation from PrintDialog?
Do I have to set the PrintableAreaHeight/Width, and how do I do so?
I got it.
PrintDialog prnt = new PrintDialog();
if (prnt.ShowDialog() == true)
{
Size pageSize = new Size(prnt.PrintableAreaWidth - 30, prnt.PrintableAreaHeight - 30);
PrntFrm.Measure(pageSize);
PrntFrm.Arrange(new Rect(15, 15, pageSize.Width, pageSize.Height));
prnt.PrintVisual(PrntFrm, "Work Request");
}
is for a potrait screen. sizes may change depending on the amount needed to print
and
PrintDialog prnt = new PrintDialog();
if (prnt.ShowDialog() == true)
{
prnt.PrintTicket.PageOrientation = System.Printing.PageOrientation.Landscape;
Size pageSize = new Size(prnt.PrintableAreaWidth + 30, prnt.PrintableAreaHeight + 300);
PrntFrm.Measure(pageSize);
PrntFrm.Arrange(new Rect(15, 15, pageSize.Height, pageSize.Width));
prnt.PrintVisual(PrntFrm, "Job Card");
}
is for landscape. again, size changes when needed

Add a new item in a SQL Server database with wcf web service

I'm using WCF to show data from a SQL Server database in a WPF application with grid.
How can I add a new row to the database using WCF web services?
My service code
public class abalaseService : DataService<eshop2Entities>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(IDataServiceConfiguration config)
{
config.SetEntitySetAccessRule("tblProduct", EntitySetRights.All);
}
}
In XAML
<Grid Grid.Row="1" HorizontalAlignment="Left" Margin="38,16,0,0" Name="grid1" VerticalAlignment="Top" DataContext="{Binding}">
<Grid.ContextMenu>
<ContextMenu AllowDrop="True" />
</Grid.ContextMenu>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</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" />
</Grid.RowDefinitions>
<Label Content="Ενεργό:" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
<CheckBox Content="" Grid.Column="1" Grid.Row="0" Height="16" HorizontalAlignment="Left" IsChecked="{Binding Path=Active, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" Margin="3" Name="activeCheckBox" VerticalAlignment="Center" />
<Label Content="Id Προμηθευτή:" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="3" Name="brandIdTextBox" Text="{Binding Path=BrandId, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
<Label Content="Id Κατηγορίας:" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="3" Name="categoryIdTextBox" Text="{Binding Path=CategoryId, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
<Label Content="Περιγραφή:" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Grid.Row="3" Height="23" HorizontalAlignment="Left" Margin="3" Name="descriptionTextBox" Text="{Binding Path=Description, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
<Label Content="Id:" Grid.Column="0" Grid.Row="4" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Grid.Row="4" Height="23" HorizontalAlignment="Left" Margin="3" Name="idTextBox" Text="{Binding Path=Id, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
<Label Content="Όνομα:" Grid.Column="0" Grid.Row="5" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Grid.Row="5" Height="23" HorizontalAlignment="Left" Margin="3" Name="nameTextBox" Text="{Binding Path=Name, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
<Label Content="Τιμή Αγοράς:" Grid.Column="0" Grid.Row="6" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Grid.Row="6" Height="23" HorizontalAlignment="Left" Margin="3" Name="purchasePriceTextBox" Text="{Binding Path=PurchasePrice, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
<Label Content="Απόθεμα:" Grid.Column="0" Grid.Row="7" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Grid.Row="7" Height="23" HorizontalAlignment="Left" Margin="3" Name="quantityTextBox" Text="{Binding Path=Quantity, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
<Label Content="Τιμή Πώλησης:" Grid.Column="0" Grid.Row="8" HorizontalAlignment="Left" Margin="3" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Grid.Row="8" Height="23" HorizontalAlignment="Left" Margin="3" Name="salePriceTextBox" Text="{Binding Path=SalePrice, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
</Grid>
I'd like a clear grid that user can fill and save the record to db (add a new product)
How can I do that?
I'm new to WCF and web services

Scrollviewer visibility after debugging

I have a WPF Application. I added a scrollviewer to a window. However I can see the scrollviewer during the design. When I debug the project then the scrollviewer does not seem...
There is the code
</local:WorkControl.DataContext>
<ScrollViewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
<Grid Name="mainGrid" VerticalAlignment="Top">
<Grid.Background>
<ImageBrush Stretch="Fill" TileMode="FlipXY" Viewport="0,0,1479,437" ViewportUnits="Absolute" />
</Grid.Background>
<DockPanel HorizontalAlignment="Stretch" Margin="1,1,1,1" Name="dockPanel1" VerticalAlignment="Top" Width="Auto">
<Grid Name="grid1" Width="Auto" Margin="0" VerticalAlignment="Top" DockPanel.Dock="Top" OpacityMask="Black" ShowGridLines="False" OverridesDefaultStyle="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="250" />
<ColumnDefinition Width="310" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="123" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border Grid.ColumnSpan="3" BorderBrush="Silver" BorderThickness="1" HorizontalAlignment="Left" Margin="2" Name="borAdrTopR" VerticalAlignment="Top" CornerRadius="5"
AllowDrop="False">
<Canvas Width="834" Height="40" HorizontalAlignment="Stretch" Margin="0" VerticalAlignment="Stretch" Name="panelTop" ContextMenuOpening="panelTop_ContextMenuOpening">
<TextBlock Name="txAdrID" Canvas.Left="11" Canvas.Top="11" Height="20" Text="AdrID:" Width="44" Foreground="Silver" FontWeight="Bold" />
<TextBox Text="{Binding [AdrID]}" Height="20" HorizontalAlignment="Right" Margin="0,11,602,0" Name="tbAdrID" Width="86" VerticalAlignment="Top" FontWeight="Bold"
VerticalContentAlignment="Top" Foreground="Silver" Canvas.Left="54" Canvas.Top="-1" Padding="1" BorderThickness="0" IsReadOnly="True" Background="{x:Null}" />
<TextBlock Canvas.Left="488" Canvas.Top="11" Height="20" Text="Adresspool:" Width="70" TextAlignment="Right" />
<CheckBox Canvas.Left="570" Canvas.Top="11" Content="MSS" Height="16" Name="chkMSSPool" Checked="chkPool_Checked" Unchecked="chkPool_Checked" />
<CheckBox Canvas.Left="620" Canvas.Top="11" Content="GMM" Height="16" Name="chkGMMPool" Checked="chkPool_Checked" Unchecked="chkPool_Checked" />
<CheckBox Canvas.Left="675" Canvas.Top="11" Content="MZ" Height="16" Name="chkMZPool" Checked="chkPool_Checked" Unchecked="chkPool_Checked" IsEnabled="False" />
<CheckBox Canvas.Left="728" Canvas.Top="11" Content="Sage" Height="16" Name="chkSagePool" Checked="chkPool_Checked" Unchecked="chkPool_Checked" />
<CheckBox Canvas.Left="780" Canvas.Top="11" Content="Web" Height="16" Name="chkMyMalikPool" IsEnabled="False" Checked="chkPool_Checked" Unchecked="chkPool_Checked" />
<TextBox Background="{x:Null}" BorderThickness="0" Canvas.Left="367" Canvas.Top="9" FontWeight="Bold" Foreground="Red" Height="21" IsReadOnly="True" Name="tbSecInfo"
Padding="1" Text="" VerticalContentAlignment="Top" Width="101" />
<Image Canvas.Left="268" Canvas.Top="11" Height="16" Name="imgCRMstatus" Stretch="None" Width="96" MouseLeftButtonUp="imgCRMstatus_MouseClick"
MouseRightButtonUp="imgCRMstatus_MouseClick" />
<Label Canvas.Left="257" Canvas.Top="17" Height="11" Name="lbCRMStatus" Width="9" IsEnabled="False" />
<Image Canvas.Left="466" Canvas.Top="7" Height="24" Name="imgSec" Stretch="None" Width="24" MouseRightButtonUp="imgSec_MouseClick" MouseLeftButtonUp="imgSec_MouseClick"
Visibility="Hidden" />
</Canvas>
</Border>
<Border Grid.Row="1" BorderBrush="Silver" BorderThickness="1" HorizontalAlignment="Left" Name="borAddress" VerticalAlignment="Top" CornerRadius="5" Background="White"
AllowDrop="False">
<FlowDocumentScrollViewer HorizontalAlignment="Left" Name="fdocview" VerticalAlignment="Top" Height="Auto" VerticalScrollBarVisibility="Auto" Background="#FFFFFFF9"
Margin="2" HorizontalContentAlignment="Left" Padding="0" MinHeight="118">
<FlowDocument TextAlignment="Left" FontSize="12" PagePadding="5">
<FlowDocument.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="FontSize" Value="13" />
<Setter Property="Foreground" Value="DarkBlue" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="Margin" Value="0,0,0,0" />
</Style>
</FlowDocument.Resources>
<Paragraph>ViewControl...mmm</Paragraph>
</FlowDocument>
</FlowDocumentScrollViewer>
</Border>
<Border Grid.Row="1" Grid.Column="1" BorderBrush="Silver" BorderThickness="1" Padding="3" Name="borAdrInfoLeft" CornerRadius="6" AllowDrop="False">
<Grid VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="73" />
<ColumnDefinition />
<ColumnDefinition Width="35" />
<ColumnDefinition Width="45" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<local:ComboBoxCW Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" x:Name="cbAdrTypeID" CWListName="Adresstypen" Background="#FFC8D2E8"
SelectedID="{Binding Path=[AdrTypeID]}" SelectionChanged="cwAdrType_SelectionChanged" Margin="0,0,0,3" />
<local:ComboBoxCW Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="3" x:Name="cbGruppenID" SelectedID="{Binding [GruppenID]}" CWListName="Gruppen" Background="#FFC8D2E8"
CWListArt="withall" CWListFilter="M" Margin="0,0,0,3" />
<TextBlock Grid.Column="3" Grid.Row="0" Name="txtBedeutung" Text="$$" Width="22" TextAlignment="Center" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Grid.Row="2" Name="tbKundenNr" Canvas.Left="83" Text="{Binding [KundenNr]}" BorderBrush="#96000000" MaxLength="30" Margin="0,0,0,3" />
<TextBox Grid.Column="3" Grid.Row="2" Name="tbCRA" Text="{Binding [CRA]}" BorderBrush="#96000000" IsReadOnly="True" Margin="0,0,0,3" />
<local:ComboBoxCW Grid.Column="1" Grid.Row="3" x:Name="cwSprachID" SelectedID="{Binding [SprachID],Mode=TwoWay}" CWListName="Sprachen" CWListArt="withempty"
Margin="0,0,0,3" />
<ComboBox Grid.Column="3" Grid.Row="3" Name="cbBedeutung" Text="{Binding Path=[Bedeutung]}">
<ComboBoxItem Content=" " />
<ComboBoxItem Content="A" />
<ComboBoxItem Content="B" />
<ComboBoxItem Content="C" />
</ComboBox>
<TextBlock Grid.Column="0" Grid.Row="0" Text="Adressart" />
<TextBlock Grid.Column="0" Grid.Row="1" Text="Gruppe" />
<TextBlock Grid.Column="0" Grid.Row="2" Text="Kundennr." />
<TextBlock Grid.Column="2" Grid.Row="2" Text="CRA" TextAlignment="Right" />
<TextBlock Grid.Column="0" Grid.Row="3" Text="Sprache" />
<TextBlock Grid.Column="2" Grid.Row="3" Text="Bed." TextAlignment="Right" />
</Grid>
</Border>
<Border Grid.Row="1" Grid.Column="2" BorderBrush="Silver" BorderThickness="1" Padding="3" Name="borAdrInfoRight" CornerRadius="6" AllowDrop="False">
<Grid VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="73" />
<ColumnDefinition />
<ColumnDefinition Width="35" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<local:ComboBoxCW Grid.Row="0" Grid.Column="1" x:Name="cbAdrStatusID" SelectedID="{Binding [AdrStatusID]}" CWListName="Adressstati" Margin="0,0,0,3"
Background="#FFC8D2E8" />
<TextBox Grid.Row="0" Grid.Column="3" Grid.ColumnSpan="2" Name="tbMZunitID"
Text="{Binding [MZunitID],Mode=OneWay,Converter={StaticResource codetextfromid}, ConverterParameter=MZunits}" Margin="0,0,0,3" BorderBrush="#96000000"
IsReadOnly="True" />
<local:ComboBoxCW Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" x:Name="cbBetreuerID" Text="" Background="#FFC8D2E8" CWListName="Mitarbeiter" Margin="0,0,0,3"
SelectedID="{Binding Path=[BetreuerID]}" CWListArt="withall" />
<ListBox Grid.Row="2" Grid.Column="1" Name="listBetreuers" BorderBrush="#96000000" SelectionChanged="listBetreuers_SelectionChanged" Grid.ColumnSpan="3"
Grid.RowSpan="2" Margin="0,0,0,3" />
<Popup Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="3" OpacityMask="#00000000" Name="popAdd" StaysOpen="False" PlacementTarget="{Binding ElementName=listBetreuers}"
Placement="Bottom" HorizontalOffset="-40" VerticalOffset="-20">
<ListBox Height="160" Width="270" HorizontalAlignment="Left" Name="listAdd" VerticalAlignment="Top" SelectionChanged="listAdd_SelectionChanged" />
</Popup>
<Button Grid.Row="3" Grid.Column="4" Content="-" Height="22" Width="22" Name="btnBetreuerDel" Click="btnBetreuerDel_Click" HorizontalAlignment="Right" />
<Button Grid.Row="2" Grid.Column="4" Content="+" Height="22" Width="22" Name="btnBetreuerAdd" Click="btnBetreuerAdd_Click" HorizontalAlignment="Right" />
<Button Grid.Row="1" Grid.Column="4" Content="H" Height="22" Width="22" Name="btnBetreuerHaupt" Click="btnBetreuerHaupt_Click" HorizontalAlignment="Right" />
<TextBlock Grid.Row="0" Grid.Column="0" Text="Status" />
<TextBlock Grid.Row="0" Grid.Column="2" Text="Unit" TextAlignment="Right" Margin="2" />
<TextBlock Name="lbHauptbetrP" Visibility="Visible" Grid.Row="1" Grid.Column="0" Text="Hauptbetr." />
<TextBlock Name="lbHauptbetrF" Visibility="Hidden" Grid.Row="1" Grid.Column="0" Text="Account-Mgr." />
<TextBlock Grid.Row="2" Grid.Column="0" Text="weitere Betreuer" TextWrapping="Wrap" />
</Grid>
</Border>
<!-- ====TAB Firma start -->
<TabControl Grid.Row="2" Grid.ColumnSpan="3" Name="tabReg" Margin="0" SelectionChanged="tabReg_SelectionChanged" VerticalAlignment="Stretch" Padding="2,2">
<TabItem Header="Firma" Name="regFirma" local:HelpProvider.HelpParameter="AddressControl;Firma">
<Grid VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<!-- ====Firmen-Felder linke Seite -->
<Border Grid.Row="0" Grid.Column="0" BorderBrush="Silver" BorderThickness="1" Padding="3" Name="borFeed0" CornerRadius="6" AllowDrop="False">
<Grid Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="95" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="35" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="38" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="Firma" />
<Button Name="btnLinkFirma" Height="23" Width="23" ToolTip="Mit Firma verknüpfen..." Click="btnLinkFirma_Click" Grid.Column="0" Grid.Row="0"
HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,5,0">
<Button.Content>
<Image Source="Images/Verknuepfung_32.png" />
</Button.Content>
</Button>
<TextBox Name="tbFirma" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" Margin="0,0,0,3" Text="{Binding Path=[Firma]}" BorderBrush="#96000000"
MouseDoubleClick="tbFirma_MouseDoubleClick" MaxLength="80" AcceptsReturn="True" />
<TextBox x:Name="tbFirmazusatz" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" Margin="0,0,0,3" Text="{Binding Path=[Firmazusatz]}" BorderBrush="#96000000"
MaxLength="50" />
There are more codes
Adding to Aghilas's answer
If you have set HorizontalScrollBarVisibility, VerticalScrollBarVisibility properties to 'Auto', try setting them to Visible.

Categories