C# WPF Button "Content" is not displaying - c#

<Grid RenderTransformOrigin="0.5,0.5">
<Grid Margin="0,0,0.286,0.429" Name="LogGrid">
<PasswordBox x:Name="Password" HorizontalAlignment="Left" Margin="130,130,0,0" VerticalAlignment="Top" Width="140"/>
<TextBox x:Name="Login" HorizontalAlignment="Left" Height="20" Margin="140,90,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="120"/>
<Button x:Name="btnSignIn" Content="Sign In" HorizontalAlignment="Left" Margin="130,170,0,0" VerticalAlignment="Top" Width="65"/>
<Button x:Name="btnSignUp" Content="Sign Up" HorizontalAlignment="Left" Margin="205,170,0,0" VerticalAlignment="Top" Width="65"/>
</Grid>
<Grid Name="MainPart" Width="800" Height="600" Visibility="Hidden" HorizontalAlignment="Right">
<TextBox x:Name="Chat" HorizontalAlignment="Left" Height="540" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="800" AcceptsReturn="True" IsReadOnly="True"/>
<TextBox Name="SendString" Width="740" Height="60" Margin="0, 540, 0, 0" HorizontalAlignment="Left"/>
<Button x:Name="SendMsg" Margin="740, 540, 0, 0" Width="60" Height="60" HorizontalAlignment="Right" Content="Send" /> <-!!!!!!!!!!!!!!
</Grid>
The problem is: Button from 2nd Grid, named as "SendMsg" not displays "Content"

I just had this issue because I had set a Height attribute of 30, and also a Padding attribute of 15, so my Content had been padded right out of the visible space. :)

Try this
<Button x:Name="SendMsg" Margin="740, 540, 0, 0" Width="60" Height="60" HorizontalAlignment="Right" Text="Send" />

Sure about Visibility="Hidden"? I've tested your code (just changed Visibility="Visible") and everything is displayed correctly.

Related

Scrollbar in WPF

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>....

Textboxes don't work Windows Phone 8.1 App

I am not able to have a user input in a textbox when click it both in the Emulator and in windows phone device. I have deleted all the textboxes and replace them with new ones without any special preferences and still don't work. I have implemented the whole interface of my application and need help to solve this issue and start playing with the server connection. Also the rest of the controls all work properly. Please any ideas?
This is the corresponding interface of the code I am posting below.
This is my mainpage.xaml code: If you need anything else please let me know.
<controls:ViewPage
x:Class="Menu_and_Topbar_app__Windows_Phone_8._1_3.MainPage"
xmlns:controls="using:Menu_and_Topbar_app__Windows_Phone_8._1_3.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Menu_and_Topbar_app__Windows_Phone_8._1_3"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="#FF250D5C">
<ScrollViewer HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="5.857,6.897,8.265,12.783" RenderTransformOrigin="0.5,0.5" Height="620.32" UseLayoutRounding="False" Width="385.878" d:LayoutRounding="Auto">
<ScrollViewer.RenderTransform>
<CompositeTransform Rotation="0.309"/>
</ScrollViewer.RenderTransform>
<Pivot Name="MyPivot" IsEnabled="True" IsTapEnabled="True">
<Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize="37" SelectionHighlightColor="#FF898888" />
</DataTemplate>
</Pivot.HeaderTemplate>
<PivotItem x:Name="PivotItem1" Header="Sign In" IsEnabled="True" IsTapEnabled="True">
<Grid HorizontalAlignment="Left" Height="496" Margin="18,19,0,0" VerticalAlignment="Top" Width="311" IsTapEnabled="True" IsRightTapEnabled="True">
<Image x:Name="image" HorizontalAlignment="Left" Height="70" Margin="64,9,0,0" VerticalAlignment="Top" Width="193" Source="/Menu and Topbar app (Windows Phone 8.1)3/Pictures/logo.png" Visibility="Visible" />
<Button x:Name="button" Content="Log In" HorizontalAlignment="Left" Margin="98,409,0,0" VerticalAlignment="Top" Click="button_Click_1"/>
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="16,113,0,0" TextWrapping="Wrap" Text="Username or Email:" VerticalAlignment="Top" FontSize="16"/>
<TextBlock x:Name="textBlock2" HorizontalAlignment="Left" Margin="16,210,0,0" TextWrapping="Wrap" Text="Password:" VerticalAlignment="Top" FontSize="16"/>
<HyperlinkButton Content="Sign Up for SCP?" HorizontalAlignment="Left" Margin="17,266,0,0" VerticalAlignment="Top" FontSize="13.333" NavigateUri="http://scponline.azurewebsites.net/Home/LoginPartialView"/>
<CheckBox x:Name="checkBox" Content="Remember me?" HorizontalAlignment="Left" Margin="17,312,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="textBox" HorizontalAlignment="Left" Margin="17,137,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="275" GotFocus="textBox_GotFocus" AllowDrop="True" />
</Grid>
</PivotItem>
<PivotItem x:Name="PivotItem2" Header="Sign Up" >
<Grid HorizontalAlignment="Left" Height="496" Margin="18,19,0,0" VerticalAlignment="Top" Width="311">
<Button Content="Sign Up" HorizontalAlignment="Left" Margin="97,437,0,0" VerticalAlignment="Top" Click="Button_Click_2"/>
<TextBlock x:Name="textBlock3" HorizontalAlignment="Left" Margin="16,108,0,0" TextWrapping="Wrap" Text="Email:" VerticalAlignment="Top" FontSize="16"/>
<TextBlock x:Name="textBlock4" HorizontalAlignment="Left" Margin="16,168,0,0" TextWrapping="Wrap" Text="Password:" VerticalAlignment="Top" FontSize="16"/>
<TextBox x:Name="textBox3" HorizontalAlignment="Left" Margin="16,126,0,0" TextWrapping="Wrap" Text="username#mail.com" VerticalAlignment="Top" Height="0" Width="276" FontSize="17.593" RenderTransformOrigin="0.5,0.5">
<TextBox.RenderTransform>
<CompositeTransform ScaleY="0.9"/>
</TextBox.RenderTransform>
</TextBox>
<TextBox x:Name="textBox4" HorizontalAlignment="Left" Margin="16,187,0,0" TextWrapping="Wrap" Text="***********" VerticalAlignment="Top" Height="0" Width="276" TextChanged="textBox2_TextChanged" FontSize="17.593" RenderTransformOrigin="0.5,0.5">
<TextBox.RenderTransform>
<CompositeTransform ScaleY="0.9"/>
</TextBox.RenderTransform>
</TextBox>
<Image x:Name="image1" HorizontalAlignment="Left" Height="70" Margin="64,9,0,0" VerticalAlignment="Top" Width="193" Source="/Menu and Topbar app (Windows Phone 8.1)3/Pictures/logo.png"/>
<TextBlock x:Name="textBlock1" HorizontalAlignment="Left" Margin="16,232,0,0" TextWrapping="Wrap" Text="Name:" VerticalAlignment="Top" SelectionChanged="textBlock1_SelectionChanged" FontSize="16"/>
<TextBox x:Name="textBox5" HorizontalAlignment="Left" Margin="16,250,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="0" Width="276" TextChanged="textBox2_TextChanged" FontSize="17.593" RenderTransformOrigin="0.5,0.5">
<TextBox.RenderTransform>
<CompositeTransform ScaleY="0.9"/>
</TextBox.RenderTransform>
</TextBox>
<TextBlock x:Name="textBlock5" HorizontalAlignment="Left" Margin="16,292,0,0" TextWrapping="Wrap" Text="Name:" VerticalAlignment="Top" SelectionChanged="textBlock1_SelectionChanged" FontSize="16"/>
<TextBox x:Name="textBox6" HorizontalAlignment="Left" Margin="16,310,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="0" Width="276" TextChanged="textBox2_TextChanged" FontSize="17.593" RenderTransformOrigin="0.5,0.5">
<TextBox.RenderTransform>
<CompositeTransform ScaleY="0.9"/>
</TextBox.RenderTransform>
</TextBox>
</Grid>
</PivotItem>
</Pivot>
</ScrollViewer>
</Grid>

"Object reference not set to an instance of an object" error showing on design load in WPF

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

Switching between landscape and portrait mode using wpf in tablet devices

How could we arrange the controls on a WPF window so that it would automatically align the controls while switching between view modes occur ie between landscape and portrait mode.
<Window x:Class="Custom_Track_Reports.LoginWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="LoginWindow" >
<Viewbox Stretch="Fill">
<Grid Background="#FF58B0DF" Height="401">
<Rectangle Fill="#FFF0F3F4" Height="173" Margin="45,197,58,0" Stroke="Black" VerticalAlignment="Top" AllowDrop="True" />
<Image Height="125" Margin="340,10,330,0" VerticalAlignment="Top" Source="Images/logo_lrg.png"/>
<Label Content="Custom Track Reports" HorizontalAlignment="Left" Margin="287,147,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.607,1.112" Width="268" Height="47" FontFamily="Arial" FontSize="26" Foreground="White"/>
<TextBox Margin="128,0,0,110" TextWrapping="Wrap" VerticalAlignment="Bottom" Height="25" BorderThickness="1" FontFamily="Arial" FontSize="21" Text="" Name="userTextBox" FontStretch="Expanded" Opacity="1" HorizontalAlignment="Left" Width="546" AcceptsReturn="False" KeyDown="userTextBox_KeyDown" />
<Button x:Name="enterButton" Content="Enter" HorizontalAlignment="Right" Margin="0,311,166,0" VerticalAlignment="Top" Width="110" Height="26" FontSize="14" Style="{DynamicResource button}" Click="enterButton_Click"/>
<Label Content="User ID" FontSize="20" FontWeight="Bold" Height="40" HorizontalAlignment="Left" Margin="122,215,0,0" Name="label1" VerticalAlignment="Top" Width="105" />
</Grid>
</Viewbox>

How to make a Silverlight app take up the entire browser width/height?

I have a page that is just an ASP-hosted Silverlight 4 object. I would like it to take up the full width and height of the browser, but it is not - it is too small, in a corner. Where can I adjust this?
I'm new to Silverlight. Thanks for the help.
Edit: Here is the .xaml:
<UserControl x:Class="ExpenseCalc_SilverLight.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
<Grid x:Name="LayoutRoot" Background="White" Height="Auto" Width="Auto">
<Rectangle Height="441" HorizontalAlignment="Left" Margin="-21,-14,0,0" Name="rectangle1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="583" Fill="#FFA86E6E" Opacity="1" />
<TextBlock Height="114" HorizontalAlignment="Left" Margin="13,14,0,0" Name="textBlock1" Text="Current Expenses" VerticalAlignment="Top" Width="424" FontSize="28" />
<sdk:DataGrid AutoGenerateColumns="True" Height="78" HorizontalAlignment="Left" Margin="13,60,0,0" Name="CurrentExpensesGrid" VerticalAlignment="Top" Width="494" />
<TextBlock FontSize="15" Height="114" HorizontalAlignment="Left" Margin="12,158,0,0" Name="textBlock2" Text="Add New" VerticalAlignment="Top" Width="424" />
<sdk:Label Height="18" HorizontalAlignment="Left" Margin="13,187,0,0" Name="label1" VerticalAlignment="Top" Width="48" Content="Name" />
<TextBox Text="{Binding Name, Mode=TwoWay}" Height="23" HorizontalAlignment="Left" Margin="13,205,0,0" Name="NameTextBox" VerticalAlignment="Top" Width="74" />
<sdk:Label Content="Date" Height="18" HorizontalAlignment="Left" Margin="97,187,0,0" Name="label2" VerticalAlignment="Top" Width="48" />
<sdk:Label Content="Cost" Height="18" HorizontalAlignment="Left" Margin="203,187,0,0" Name="label3" VerticalAlignment="Top" Width="48" />
<sdk:Label Content="Who paid" Height="18" HorizontalAlignment="Left" Margin="257,187,0,0" Name="label4" VerticalAlignment="Top" Width="63" />
<TextBox Text="{Binding Cost, Mode=TwoWay, ValidatesOnExceptions=True}" Height="23" HorizontalAlignment="Left" Margin="203,205,0,0" Name="CostTextBox" VerticalAlignment="Top" Width="48" />
<sdk:Label Content="Who owes" Height="18" HorizontalAlignment="Left" Margin="337,187,0,0" Name="label5" VerticalAlignment="Top" Width="63" />
<sdk:AutoCompleteBox Height="23" HorizontalAlignment="Left" Margin="337,205,0,0" Name="WhoOwesInput" VerticalAlignment="Top" Width="74" ValueMemberBinding="{Binding}" LostFocus="WhoOwesInput_LostFocus" />
<sdk:Label Content="Receipt" Height="18" HorizontalAlignment="Left" Margin="417,187,0,0" Name="label6" VerticalAlignment="Top" Width="63" />
<Button Content="Add" Height="30" HorizontalAlignment="Left" Margin="337,154,0,0" Name="AddButton" VerticalAlignment="Top" Width="155" FontSize="15" Click="AddButton_Click" />
<sdk:DatePicker Text="{Binding Date, Mode=TwoWay}" Height="23" HorizontalAlignment="Left" Margin="97,205,0,0" Name="datePicker1" VerticalAlignment="Top" Width="100" />
<ComboBox Height="23" HorizontalAlignment="Left" Margin="257,205,0,0" Name="WhoPaidComboBox" VerticalAlignment="Top" Width="74" />
<ListBox Height="100" HorizontalAlignment="Left" Margin="337,232,0,0" Name="WhoOwesListBox" VerticalAlignment="Top" Width="74" KeyDown="WhoOwesListBox_KeyDown" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="418,205,0,0" Name="textBox1" VerticalAlignment="Top" Width="74" />
</Grid>
</UserControl>
When you create a SL application and choose to create a Web Applicatio, the VS template creates a .html file that does exactly what you are looking for. The key parts are the following
<style type="text/css">
html, body {
height: 100%;
overflow: auto;
}
body {
padding: 0;
margin: 0;
}
#silverlightControlHost {
height: 100%;
text-align:center;
}
</style>
And in the <form> the control is wrapped in a <div id="silverlightControlHost"> element.
I would suggest you create a quick test app, select the option to create a hosting web application and then take the markup from there.
Check if your usercontrols are hardcoded some size

Categories