Related
I am trying to design a page in WPF that requires a scroll bar as there is a lot of contet on this particular page. Since there are different types of infomration that need to be inputted, I have put the different parts in different grids. I have then set the ScrollViewer and put all the grids inside this but when I run it it does not work. Here is my code:
<Page x:Class="uniFirstGo.AddStudent"
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:local="clr-namespace:mosque"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="AddStudent">
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<Grid Margin="0,0,0,-751">
<Grid.RowDefinitions>
<RowDefinition Height="593*"/>
<RowDefinition Height="154*"/>
<RowDefinition Height="46*"/>
<RowDefinition Height="44*"/>
</Grid.RowDefinitions>
<Label Name="ChildsDetails" Content="Childs Details" HorizontalAlignment="Left" Height="24" Margin="350,10,0,0" VerticalAlignment="Top" Width="91"/>
<Grid HorizontalAlignment="Left" Height="178" Margin="20,54,0,0" VerticalAlignment="Top" Width="770">
<Label x:Name="ChildsSurname" Content="Childs Surname" HorizontalAlignment="Left" Height="24" Margin="10,14,0,0" VerticalAlignment="Top" Width="97"/>
<TextBox x:Name="childsSurname" HorizontalAlignment="Left" Height="24" Margin="107,14,0,0" VerticalAlignment="Top" Width="145" SpellCheck.IsEnabled="True"/>
<Label x:Name="ChildsFirstName" Content="Childs First Name" HorizontalAlignment="Left" Height="24" Margin="276,14,0,0" VerticalAlignment="Top" Width="105"/>
<TextBox x:Name="childsFirstName" HorizontalAlignment="Left" Height="24" Margin="386,14,0,0" VerticalAlignment="Top" Width="155"/>
<Label Content="Address" HorizontalAlignment="Left" Margin="10,54,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.605,0.288" Width="97"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="107,54,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="468" Grid.ColumnSpan="2"/>
<Label Content="Date of Birth
" HorizontalAlignment="Left" Margin="10,92,0,0" VerticalAlignment="Top" Height="25" Width="83"/>
<DatePicker HorizontalAlignment="Left" Margin="107,93,0,0" VerticalAlignment="Top" Width="130"/>
<Label Content="Postcode" HorizontalAlignment="Left" Margin="600,54,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.368,-0.154"/>
<TextBox x:Name="childsGender_Copy" HorizontalAlignment="Left" Height="24" Margin="663,54,0,0" VerticalAlignment="Top" Width="97"/>
<Label Content="Age" HorizontalAlignment="Left" Margin="10,132,0,0" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="107,132,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="130"/>
<Label Content="Gender
" HorizontalAlignment="Left" Margin="578,10,0,0" VerticalAlignment="Top" Height="26"/>
<CheckBox Content="Male
" HorizontalAlignment="Left" Margin="651,16,0,0" VerticalAlignment="Top"/>
<CheckBox Content="Female" HorizontalAlignment="Left" Margin="702,16,0,0" VerticalAlignment="Top"/>
</Grid>
<Label Content="Parents Details" HorizontalAlignment="Left" Margin="350,249,0,0" VerticalAlignment="Top"/>
<Grid HorizontalAlignment="Left" Height="201" Margin="10,280,0,0" VerticalAlignment="Top" Width="780">
<Label Content="Fathers Full Name
" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="134" Height="28" RenderTransformOrigin="0.5,0.5"></Label>
<Label Content="Mothers Full Name" HorizontalAlignment="Left" Margin="10,46,0,0" VerticalAlignment="Top" Width="120" Height="29"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,15,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="138"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,52,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="138"/>
<Label Content="Fathers Address
" HorizontalAlignment="Left" Margin="10,80,0,0" VerticalAlignment="Top" Width="107" Height="28"/>
<Label Content="Mothers Address
" HorizontalAlignment="Left" Margin="10,113,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.132,-0.154" Width="107" Height="28"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,85,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="640"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,118,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="640"/>
<Label Content="Fathers Phone Number
" HorizontalAlignment="Left" Margin="283,12,0,0" VerticalAlignment="Top" Height="26"/>
<Label Content="Mothers Phone Number
" HorizontalAlignment="Left" Margin="283,46,0,0" VerticalAlignment="Top" Height="26"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="426,16,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="426,49,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<Label Content="Mothers Date of Birth" HorizontalAlignment="Left" Margin="554,48,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.48,0.077"/>
<DatePicker HorizontalAlignment="Left" Margin="679,15,0,0" VerticalAlignment="Top" Width="101"/>
<DatePicker HorizontalAlignment="Left" Margin="679,48,0,0" VerticalAlignment="Top" Width="101"/>
<Label Content="Father Date of Birth
" HorizontalAlignment="Left" Margin="554,16,0,0" VerticalAlignment="Top" Height="25"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,153,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="253"/>
<Label Content="Fathers Email" HorizontalAlignment="Left" Margin="10,150,0,0" VerticalAlignment="Top" Width="107"/>
<Label Content="Mothers Email" HorizontalAlignment="Left" Margin="405,150,0,0" VerticalAlignment="Top" Width="107"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="517,153,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="253"/>
</Grid>
<Label Content="Emergency Contact Details
" HorizontalAlignment="Left" Margin="328,486,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.895,-2.308" Height="29"/>
<Grid HorizontalAlignment="Left" Height="82" Margin="10,520,0,0" VerticalAlignment="Top" Width="780" Grid.RowSpan="2">
<Label Content="Surname
" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="88" Height="29"/>
<Label Content="Surname
" HorizontalAlignment="Left" Margin="10,44,0,0" VerticalAlignment="Top" Width="88" Height="29"/>
<Label Content="First Name
" HorizontalAlignment="Left" Margin="258,44,0,0" VerticalAlignment="Top" Width="88" Height="29" RenderTransformOrigin="0.114,0.448"/>
<Label Content="First Name
" HorizontalAlignment="Left" Margin="258,10,0,0" VerticalAlignment="Top" Width="88" Height="29"/>
<Label Content="Contact Number
" HorizontalAlignment="Left" Margin="513,44,0,0" VerticalAlignment="Top" Width="98" Height="29"/>
<Label Content="Contact Number
" HorizontalAlignment="Left" Margin="513,10,0,0" VerticalAlignment="Top" Width="98" Height="29"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="618,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="74,50,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="336,14,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="74,16,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="618,44,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="336,50,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
</Grid>
<Label Content="Medical, Disability and Special Needs
" HorizontalAlignment="Left" Margin="298,617,0,0" VerticalAlignment="Top" Height="26"/>
<Grid HorizontalAlignment="Left" Height="145" Margin="10,648,0,0" VerticalAlignment="Top" Width="780">
<Label Content="Name of Surgery
" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="34"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="116,12,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="175"/>
<Label Content="Surgery Telephone Number
" HorizontalAlignment="Left" Margin="337,10,0,0" VerticalAlignment="Top" Height="34"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="512,12,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="258"/>
<Label Content="Surgery Address" HorizontalAlignment="Left" Margin="10,44,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.289,-0.038" Width="100" Height="31"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="116,49,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="654"/>
</Grid>
</Grid>
</ScrollViewer>
</Page>
Can someone tell me whats going wrong here and why the scroll bar isnt working please?
Thanks.
I set your page as the Content of my WPF main window, which has dimensions of 300x400. And this is what I get:
As you can see the horizontal scroll bar is visible and working quite fine, but the vertical isn't.
But note that for some reason you've set your Grid.Margin to an unusual -751.
<Grid Margin="0,0,0,-751">
The four numbers in Margin are defined as follows:
<Grid Margin="left, top, right, bottom">
So let's take a simpler example. I have the following two Grid controls, one inside another, inside my main window.
<Window x:Class="StackOverflowWPF.MainWindow"
...
Title="MainWindow" Height="300" Width="400">
<Grid Margin="20" Background="LightSeaGreen">
<Grid Margin="5, 10, 15, 20" Background="LightGoldenrodYellow"/>
</Grid>
</Window>
And the designer is like below:
So the inner grid left is 5 pixels from it's container grid, top is 10 from it's container, etc. You get the drift. But see what happens when I set the bottom to a negative number.
<Grid Margin="20" Background="LightSeaGreen">
<Grid Margin="5, 10, 15, -20" Background="LightGoldenrodYellow"/>
</Grid>
Designer:
You're essentially telling XAML that the inner Grid can be outside the outer grid, which kind of defeats the purpose of a margin to begin with.
Now let's go back to your problem. A scroll bar lets you scroll contents in case content is larger than the container. But by speficying a negative margin, you're saying your grid can go 751 pixels below the bottom, essentially rendering the scroll bar useless.
Instead, look what happens you set the margin to a reasonable 0.
<Grid>
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<Grid Margin="0,0,0,0">
The output:
Just remove the Margin="0,0,0,-751" in the main grid:
<Page x:Class="uniFirstGo.AddStudent"
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:local="clr-namespace:mosque"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="AddStudent">
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<Grid>
<Grid.RowDefinitions>....
I need help at replacing some xaml-code with user control.
I have two tabs in main window and I would like to put the second tab (shown with Header=WCF) in user control.
Here is my code:
<Window x:Class="TesterTool.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:gif="http://wpfanimatedgif.codeplex.com"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:helpers="clr-namespace:TesterTool"
xmlns:da ="clr-namespace:TesterTool.DatabaseAccess"
xmlns:converters="clr-namespace:TesterTool.Converters"
xmlns:vm="clr-namespace:TesterTool"
Title="TestingTool v1.00" Height="350" Width="725"
Icon="Icon.ico">
<Window.Resources>
<converters:BoolVisibilityConverter x:Key="BoolVisibilityConverter" />
<converters:InvertedBoolVisibilityConverter x:Key="InvertedBoolVisibilityConverter"/>
</Window.Resources>
<TabControl>
<TabItem Header="WPF" Margin="-2,0" Height="22" VerticalAlignment="Bottom">
<Grid>
<Grid.Background>
<ImageBrush ImageSource="image.png"/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Image gif:ImageBehavior.AnimatedSource="332.gif"
Width="152"
Height="39"
Margin="10,69,194,37"
Grid.Row="1"
Visibility="{Binding IsLoading, Converter={StaticResource BoolVisibilityConverter}}"/>
<TextBox x:Name="tb1"
Text ="{Binding BoxSerialNumber}"
Height="23" Margin="128,26,0,0"
TextWrapping="Wrap"
VerticalAlignment="Top"
HorizontalAlignment="Left" Width="220"
/>
<TextBox x:Name="tbn2"
Visibility="{Binding IsViewLogSelected, Converter={StaticResource InvertedBoolVisibilityConverter}}"
Height="23" Margin="128,73,8,0"
TextWrapping="Wrap"
Text="{Binding HardwareID}"
VerticalAlignment="Top"
RenderTransformOrigin="0.494,0.478"/>
<TextBox x:Name="tbb3"
HorizontalAlignment="Left"
Height="23"
Margin="128,116,0,0"
TextWrapping="Wrap"
Text="{Binding CompanyContext}"
VerticalAlignment="Top" Width="220"/>
<Label Content="Box Serial Number" HorizontalAlignment="Left" Margin="0,26,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.526,0.5"/>
<Label Content="Hardware ID" HorizontalAlignment="Left" Margin="0,73,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.526,0.5"/>
<Label Content="Company Context" HorizontalAlignment="Left" Margin="3,113,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.526,0.5"/>
<StackPanel Grid.Row="1"
Orientation="Horizontal"
Visibility="{Binding IsTrafficLogSelected, Converter={StaticResource BoolVisibilityConverter}}">
<Label Content="Start Date"
HorizontalAlignment="Left"
Grid.Row="1"
VerticalAlignment="Top"/>
<DatePicker x:Name="dp1"
SelectedDate="{Binding StartDate}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Height="25"/>
<Label Content="End Date"
HorizontalAlignment="Left"
Grid.Row="1"
VerticalAlignment="Top"/>
<DatePicker x:Name="dp2"
SelectedDate="{Binding EndDate}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Height="25"/>
</StackPanel>
<StackPanel Grid.Row="1"
Orientation="Horizontal"
Visibility="{Binding IsTransmissionLogSelected, Converter={StaticResource BoolVisibilityConverter}}">
<Label Content="Start Date"
HorizontalAlignment="Left"
Grid.Row="1"
VerticalAlignment="Top"/>
<DatePicker x:Name="dp13"
SelectedDate="{Binding StartDate}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Height="25"/>
<Label Content="End Date"
HorizontalAlignment="Left"
Grid.Row="1"
VerticalAlignment="Top"/>
<DatePicker x:Name="dp23"
SelectedDate="{Binding EndDate}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Height="25"/>
</StackPanel>
<StackPanel Grid.Row="1"
Orientation="Horizontal"
Visibility="{Binding IsCreditLogSelected, Converter={StaticResource BoolVisibilityConverter}}">
<Label Content="Log date"
HorizontalAlignment="Left"
Grid.Row="1"
VerticalAlignment="Top"/>
<DatePicker x:Name="dp12"
SelectedDate="{Binding LogDate}"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Height="25" Width="102"/>
</StackPanel>
<StackPanel Grid.Row="1"
Orientation="Horizontal"
Visibility="{Binding IsViewLogSelected, Converter={StaticResource BoolVisibilityConverter}}">
</StackPanel>
<Label Content="VesselIMO" HorizontalAlignment="Left" Margin="32,70,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.526,0.5" Grid.Column="1"/>
<Label Content="Select Type" Grid.Column="1" HorizontalAlignment="Left" Margin="32,22,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name ="cb"
ItemsSource="{Binding LogTypes}"
SelectedItem="{Binding SelectedItem}"
Margin="164,26,23,0" VerticalAlignment="Top"
Grid.Column="1">
</ComboBox>
<TextBox x:Name="tb3_Copy"
Visibility="{Binding IsViewLogSelected, Converter={StaticResource InvertedBoolVisibilityConverter}}"
HorizontalAlignment="Left"
Height="23"
Margin="164,73,0,0"
TextWrapping="Wrap"
Text="{Binding VesselIMO}"
VerticalAlignment="Top"
Width="172" Grid.Column="1"/>
<Button Name ="Button1"
Content="Submit"
Grid.Column="1"
HorizontalAlignment="Left"
Margin="197,81,0,0"
Grid.Row="1"
VerticalAlignment="Top"
Width="152"
Height="39"
Click="Button1Clicked"
IsEnabled="{Binding IsLoading, Converter={StaticResource InvertedBoolVisibilityConverter}}"/>
<TextBox Grid.Column="1"
HorizontalAlignment="Left"
Height="23"
Margin="164,120,0,0"
TextWrapping="Wrap"
Text ="{Binding Counter}"
VerticalAlignment="Top"
Width="91"/>
<Label Content="Number of rows" Grid.Column="1" HorizontalAlignment="Left" Margin="32,116,0,0" VerticalAlignment="Top"/>
</Grid>
</TabItem>
<TabItem Header="WCF">
<Grid Background="#FFE5E5E5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Content="User Credentials" HorizontalAlignment="Left" Margin="10,20,0,0" VerticalAlignment="Top" Grid.ColumnSpan="2" Height="26" Width="96"/>
<Label Content="Username" HorizontalAlignment="Left" Margin="10,69,0,0" VerticalAlignment="Top" Grid.ColumnSpan="2" Height="26" Width="63"/>
<Label Content="Password" HorizontalAlignment="Left" Margin="10,120,0,0" VerticalAlignment="Top" Grid.ColumnSpan="2" Height="26" Width="60"/>
<TextBox x:Name="unTB"
Text="{Binding Username}"
HorizontalAlignment="Left"
Height="22"
Margin="103,73,0,0"
TextWrapping="Wrap"
VerticalAlignment="Top"
Width="179"
Grid.Column="1"/>
<Label Content="Box ID"
HorizontalAlignment="Left"
Margin="384,73,0,0"
VerticalAlignment="Top"
Grid.Column="1"
Height="26"
Width="44"/>
<Label Content="Software Version" HorizontalAlignment="Left" Margin="384,124,0,0" VerticalAlignment="Top" Grid.Column="1" Height="26" Width="99"/>
<TextBox x:Name="boxTB"
Text="{Binding BoxID}"
HorizontalAlignment="Left"
Height="22"
Margin="501,73,0,0"
TextWrapping="Wrap"
VerticalAlignment="Top"
Width="179"
Grid.Column="1"/>
<TextBox
Text ="{Binding SoftwareId}"
x:Name="SIBox"
HorizontalAlignment="Left"
Height="22"
Margin="501,124,0,0"
TextWrapping="Wrap"
VerticalAlignment="Top"
Width="179"
Grid.Column="1"/>
<Button Content="Create Box" HorizontalAlignment="Left" Margin="538,233,0,0" VerticalAlignment="Top" Width="142" Height="35" Click="Button_Click" Grid.Column="1" Command="{Binding CreateBoxCommand}"/>
<TextBox x:Name="pass"
Text ="{Binding Password}"
HorizontalAlignment="Left"
Height="22"
Margin="103,120,0,0"
TextWrapping="Wrap"
VerticalAlignment="Top"
Width="179"
Grid.Column="1"/>
</Grid>
</TabItem>
</TabControl>
Does anyone knows how to do this in proper way?
Put entire Grid and its contents present in your TabItem(WCF) in a user-control, and name this UserControl as WCFTabUserControl.
Reference the namespace in your Window tag like : xmlns:uc="clr-namespace:WpfApplication1"
Use your user-control :
<TabItem Header="WCF">
<uc:WCFTabUserControl/>
</TabItem>
I have seen many questions on the same topic here, and tried almost all solutions recommended, But still not getting it cleared. So please kindly let me know any new updates on this.
<UserControl x:Class="ClinicManagement_Forms.ClinicDetails"
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:view="clr-namespace:ClinicManagement_Forms"
mc:Ignorable="d" Background="White" HorizontalAlignment="Center" VerticalAlignment="Center" Width="875" Height="474">
<UserControl.DataContext>
<view:ClinicRegistrationViewModel/>
</UserControl.DataContext>
<Grid>
<Grid.Resources>
<ControlTemplate x:Key="LeftErrorTemplate">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding AdornedElement.(Validation.Errors).[0].ErrorContent, ElementName=ErrorAdorner}" Background="LightCoral" Foreground="White" VerticalAlignment="Center"/>
<AdornedElementPlaceholder x:Name="ErrorAdorner">
<Border BorderBrush="LightCoral" BorderThickness="1" />
</AdornedElementPlaceholder>
</StackPanel>
</ControlTemplate>
</Grid.Resources>
<TextBlock HorizontalAlignment="Left" Margin="2,0,0,444" TextWrapping="Wrap" Text="Clinic Registration" VerticalAlignment="Bottom" Width="873" Height="30" TextAlignment="Center" FontSize="18" FontFamily="Showcard Gothic" />
<TextBlock HorizontalAlignment="Left" Margin="91,99,0,0" TextWrapping="Wrap" Text="Clinic Name" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="202,96,0,0" TextWrapping="Wrap" Text="{Binding CliicRegistation.ClinicName , UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource LeftErrorTemplate}" VerticalAlignment="Top" Width="200"/>
<TextBlock HorizontalAlignment="Left" Margin="91,136,0,0" TextWrapping="Wrap" Text="Address" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" VerticalScrollBarVisibility="Visible" Height="58" Margin="202,133,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="200" AcceptsReturn="True"/>
<TextBlock HorizontalAlignment="Left" Margin="91,210,0,0" TextWrapping="Wrap" Text="Place" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="202,207,0,0" TextWrapping="Wrap" Text="{Binding CliicRegistation.Place, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="200"/>
<TextBlock HorizontalAlignment="Left" Margin="91,250,0,0" TextWrapping="Wrap" Text="Phone No" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="202,247,0,0" TextWrapping="Wrap" Text="{Binding CliicRegistation.PhonNo , UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource LeftErrorTemplate}" VerticalAlignment="Top" Width="200" IsReadOnlyCaretVisible="True"/>
<TextBlock HorizontalAlignment="Left" Margin="91,289,0,0" TextWrapping="Wrap" Text="User Name" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="202,286,0,0" TextWrapping="Wrap" Text="{Binding CliicRegistation.UserName, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="200"/>
<TextBlock HorizontalAlignment="Left" Margin="91,329,0,0" TextWrapping="Wrap" Text="Password" VerticalAlignment="Top"/>
<PasswordBox HorizontalAlignment="Left" Height="23" Margin="202,329,0,0" Name="passwordBox1" Validation.ErrorTemplate="{StaticResource LeftErrorTemplate}" VerticalAlignment="Top" Width="200"/>
<TextBlock HorizontalAlignment="Left" Margin="91,367,0,0" TextWrapping="Wrap" Text="Confirm Password" VerticalAlignment="Top"/>
<PasswordBox HorizontalAlignment="Left" Height="23" Margin="202,367,0,0" PasswordChar="{Binding CliicRegistation.ConformPassword, Mode=TwoWay ,UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{StaticResource LeftErrorTemplate}" VerticalAlignment="Top" Width="200"/>
<Button IsEnabled="{Binding CliicRegistation.AllPropertiesValid}" Content="Save" Command="{Binding SaveCommand}" HorizontalAlignment="Left" Margin="202,441,0,0" VerticalAlignment="Top" Width="75"/>
<Button IsEnabled="{Binding CliicRegistation.AllPropertiesValid}" Content="Delete" HorizontalAlignment="Left" Margin="299,441,0,0" VerticalAlignment="Top" Width="75"/>
<Button Content="Clear" HorizontalAlignment="Left" Margin="397,441,0,0" VerticalAlignment="Top" Width="75"/>
<Image HorizontalAlignment="Left" Height="100" Margin="536,89,0,0" VerticalAlignment="Top" Width="100"/>
<Image HorizontalAlignment="Left" Height="100" Margin="561,89,0,0" VerticalAlignment="Top" Width="148" OpacityMask="#FFD44949"/>
<Button Content="Select" HorizontalAlignment="Left" Margin="559,207,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="5.053,-10.4"/>
<Button Content="Clear" HorizontalAlignment="Left" Margin="647,208,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="5.053,-10.4"/>
</Grid>
It is the code I had tried, when i click on design mode, This error is shown.
Thanks in advance
I need to use the same page for Updating my details.. can any one help me to design it..
Here is my Design code of XAML for Adding data..
<Grid x:Name="ContentPanel" Margin="12,157,12,4" Grid.RowSpan="2">
<TextBlock HorizontalAlignment="Left" Height="30" Margin="20,67,0,0" TextWrapping="Wrap" Text="Name" VerticalAlignment="Top" Width="65"/>
<TextBox x:Name="txt_name" HorizontalAlignment="Left" Height="73" Margin="121,42,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315" BorderThickness="0" InputScope="PersonalFullName"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="20,115,0,0" TextWrapping="Wrap" Text="Address" VerticalAlignment="Top" Width="75"/>
<TextBox x:Name="txt_address" HorizontalAlignment="Left" Height="78" Margin="121,110,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315" BorderThickness="0" InputScope="PostalAddress"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="20,197,0,0" TextWrapping="Wrap" Text="City" VerticalAlignment="Top" Width="65"/>
<TextBox x:Name="txt_city" HorizontalAlignment="Left" Height="73" Margin="121,178,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315" BorderThickness="0" InputScope="AddressCity"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="20,259,0,0" TextWrapping="Wrap" Text="State" VerticalAlignment="Top" Width="65"/>
<TextBox x:Name="txt_state" HorizontalAlignment="Left" Height="73" Margin="121,237,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315" BorderThickness="0" InputScope="AddressCountryShortName"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="20,324,0,0" TextWrapping="Wrap" Text="Country" VerticalAlignment="Top" Width="75"/>
<TextBox x:Name="txt_country" HorizontalAlignment="Left" Height="73" Margin="121,302,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315" BorderThickness="0" InputScope="AddressCountryName"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="20,386,0,0" TextWrapping="Wrap" Text="Web Site" VerticalAlignment="Top" Width="90"/>
<TextBox x:Name="txt_website" HorizontalAlignment="Left" Height="73" Margin="121,361,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315" BorderThickness="0" InputScope="Url"/>
</Grid>
My Button Click code is..
Organization neworganization=new Organization();
private void btn_add_organization_Click(object sender, RoutedEventArgs e)
{
neworganization = populateOrganizationDetails();
string organizationDetails = JsonConvert.SerializeObject(neworganization);
client.addNewOrganization(organizationDetails);
NavigationService.Navigate(new Uri("/HomePage.xaml", UriKind.Relative));
}
populateOrganizationDetails()
private Organization populateOrganizationDetails()
{
neworganization.name = txt_name.Text;
neworganization.address = txt_address.Text;
neworganization.city = txt_city.Text;
neworganization.country = txt_country.Text;
neworganization.website = txt_website.Text;
neworganization.state = txt_state.Text;
neworganization.region = txt_city.Text;
return neworganization;
}
Can any please help me to design the page for updating the details in same page..I would be more thank-full..
I finished my task and here i had updated my smple code..
<Grid x:Name="ContentPanel" Margin="12,157,12,4" Grid.RowSpan="2">
<ListBox x:Name="editorg" Height="579" Width="456" ItemsSource="{Binding Organization}">
<TextBlock x:Name="name_txt" HorizontalAlignment="Left" Height="34" Margin="0,78,0,0" TextWrapping="Wrap" Text="Name" VerticalAlignment="Top" Width="100" FontFamily="Segoe UI Semibold" FontSize="22" IsHitTestVisible="True" />
<TextBox x:Name="txtbx_name" HorizontalAlignment="Left" Height="70" Margin="100,50,0,0" TextWrapping="Wrap" Text="{Binding name,Mode=TwoWay}" VerticalAlignment="Top" Width="333" FontFamily="Segoe UI Semibold" FontSize="18" InputScope="Default" IsHitTestVisible="True" AcceptsReturn="True" />
<TextBlock Name="Address_txt" HorizontalAlignment="Left" Height="30" Margin="0,148,0,0" TextWrapping="Wrap" Text="Address" VerticalAlignment="Top" Width="100" FontFamily="Segoe UI Semibold" FontSize="18" />
<TextBox x:Name="txtbx_address" HorizontalAlignment="Left" Height="68" Margin="100,118,0,0" TextWrapping="Wrap" Text="{Binding address,Mode=TwoWay,UpdateSourceTrigger=Explicit}" VerticalAlignment="Top" Width="333" FontFamily="Segoe UI Semibold" FontSize="18" InputScope="AddressStreet"/>
</Listbox>
</Grid>
Do not display "host" and "port" fields. Please help find the error.
<!--ContentPanel – поместите здесь дополнительное содержимое-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="10,0,14,0">
<TextBlock HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="{Binding LocalizedResources.ConnectionName, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Top"/>
<TextBox x:Name="TitleServer" HorizontalAlignment="Left" Height="72" Margin="0,37,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="446"/>
<TextBlock HorizontalAlignment="Left" Margin="11,109,0,0" TextWrapping="Wrap" Text="{Binding LocalizedResources.Host, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Top"/>
<StackPanel Margin="0,130,10,436" Orientation="Horizontal">
<TextBox HorizontalAlignment="Left" x:Name="Host" TextWrapping="Wrap" Height="72" Width="345"/>
<TextBox HorizontalAlignment="Left" x:Name="Port" TextWrapping="Wrap" Height="72" Width="100" InputScope="Number"/>
</StackPanel>
<TextBlock HorizontalAlignment="Left" Margin="11,210,0,0" TextWrapping="Wrap" Text="{Binding LocalizedResources.Login, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Top"/>
<TextBox x:Name="Login" HorizontalAlignment="Left" Height="72" Margin="0,236,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="446"/>
<TextBlock HorizontalAlignment="Left" Margin="11,314,0,0" TextWrapping="Wrap" Text="{Binding LocalizedResources.Password, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Top"/>
<TextBox x:Name="Password" HorizontalAlignment="Left" Height="72" Margin="0,340,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="446"/>
</Grid>
Try this
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="10,0,14,0">
<TextBlock HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="{Binding LocalizedResources.ConnectionName, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Top"/>
<TextBox x:Name="TitleServer" HorizontalAlignment="Left" Height="72" Margin="0,37,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="446"/>
<TextBlock HorizontalAlignment="Left" Margin="11,109,0,0" TextWrapping="Wrap" Text="{Binding LocalizedResources.Host, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Top"/>
<StackPanel Margin="0,130,10,0" Orientation="Horizontal" VerticalAlignment="Top">
<TextBox HorizontalAlignment="Left" x:Name="Host" TextWrapping="Wrap" Height="72" Width="345"/>
<TextBox HorizontalAlignment="Left" x:Name="Port" TextWrapping="Wrap" Height="72" Width="100" InputScope="Number"/>
</StackPanel>
<TextBlock HorizontalAlignment="Left" Margin="11,210,0,0" TextWrapping="Wrap" Text="{Binding LocalizedResources.Login, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Top"/>
<TextBox x:Name="Login" HorizontalAlignment="Left" Height="72" Margin="0,236,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="446"/>
<TextBlock HorizontalAlignment="Left" Margin="11,314,0,0" TextWrapping="Wrap" Text="{Binding LocalizedResources.Password, Source={StaticResource LocalizedStrings}}" VerticalAlignment="Top"/>
<TextBox x:Name="Password" HorizontalAlignment="Left" Height="72" Margin="0,340,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="446"/>
</Grid>
The issue was with StackPanel's Margin Property. Please note that i added VerticalAlignment Property too.
Actually you simply need to use StackPanel as ContentPanel instead of
using Grid , so that you can place your controls one below one order
without giving any Margin.And that will be more easier
Set the visibility-property of the StackPanel to Collapsed or Hidden. Or, set this property on each of the TextBox controls separately if you prefer.
<StackPanel Visibility="Collpased" Margin="0,130,10,436" Orientation="Horizontal">
<TextBox HorizontalAlignment="Left" x:Name="Host" TextWrapping="Wrap" Height="72" Width="345"/>
<TextBox HorizontalAlignment="Left" x:Name="Port" TextWrapping="Wrap" Height="72" Width="100" InputScope="Number"/>
</StackPanel>
More info on the property from MSDN:
Visible: Display the element.
Hidden: Do not display the element, but reserve space for the element in layout.
Collapsed: Do not display the element, and do not reserve space for it in layout.