XAML for Windows Phone 7 - c#

I am building an app in Windows Phone 7.
I am showing a few data in different TextBlocks.
But as the data size is too big, it doesn't fit in my view.
I want to show the data like a paragraph.
If the data size exceeds the size of the emulator I want to put a ScrollBar so that the data can be scrolled and viewed.
Please help me.
I am providing my XAML design.
<Grid x:Name="ContentPanel" Margin="12,17,12,0" Grid.RowSpan="2">
<TextBlock TextAlignment="Center" Height="63" HorizontalAlignment="Right" Margin="0,6,43,0" Name="textBlock1" Text="News Details" VerticalAlignment="Top" Width="308" FontFamily="Verdana" FontSize="48" Foreground="AntiqueWhite"/>
<TextBlock Height="46" HorizontalAlignment="Left" Margin="45,333,0,0" Name="date" Text="" VerticalAlignment="Top" Width="173" FontFamily="Verdana" FontSize="24" />
<TextBlock Height="43" HorizontalAlignment="Left" Margin="45,397,0,0" Name="title" Text="" VerticalAlignment="Top" Width="373" />
<TextBlock Height="206" HorizontalAlignment="Left" Margin="45,462,0,0" Name="description" Text="" VerticalAlignment="Top" Width="373" />
<Image Height="167" HorizontalAlignment="Left" Margin="45,113,0,0" Name="newsimage" Stretch="Fill" VerticalAlignment="Top" Width="368" />
</Grid>
<Button x:Name="previous" BorderThickness="0" Click="Image_Back" Margin="0,23,431,682" HorizontalAlignment="Right" Width="76" Height="63" Grid.RowSpan="2">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Image/Previous.png" />
</Button.Background>
</Button>
</Grid>

Try this,
<Grid x:Name="ContentPanel" Margin="12,17,12,0" Grid.RowSpan="2">
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<Grid VerticalAlignment="Top" HorizontalAlignment="Left">
<TextBlock TextWrapping="Wrap" TextAlignment="Center" Height="63" HorizontalAlignment="Right" Margin="0,6,43,0" Name="textBlock1" Text="News Details" VerticalAlignment="Top" Width="308" FontFamily="Verdana" FontSize="48" Foreground="AntiqueWhite"/>
<TextBlock TextWrapping="Wrap" Height="46" HorizontalAlignment="Left" Margin="45,333,0,0" Name="date" Text="" VerticalAlignment="Top" Width="173" FontFamily="Verdana" FontSize="24" />
<TextBlock TextWrapping="Wrap" Height="43" HorizontalAlignment="Left" Margin="45,397,0,0" Name="title" Text="" VerticalAlignment="Top" Width="373" />
<TextBlock TextWrapping="Wrap" Height="206" HorizontalAlignment="Left" Margin="45,462,0,0" Name="description" Text="" VerticalAlignment="Top" Width="373" />
<Image Height="167" HorizontalAlignment="Left" Margin="45,113,0,0" Name="newsimage" Stretch="Fill" VerticalAlignment="Top" Width="368" />
</Grid>
</ScrollViewer>
</Grid>
More details
http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer(v=vs.110).aspx
http://dotnet.dzone.com/news/scrollviewer-not-scrollable

Try using Scrollable textblock. Hope that help you to solve the issue.

Related

MaterialDesign- Flipper WPF: Alignment & Scalling is skew.

I'm using the Material Design in a WPF XAML application, I've got this section of code bellow, when the grid is outside of a "materialDesign:Flipper" it all renders correctly; ie- it grows/stretch's correctly with the size of the window and it stacks nicely inside of the StackPanel.
However, as soon as I place this code inside of a Flipper, the scaling and positioning becomes skewed. If I start to change the size of the window it will resize funnily and will not stack nicely. Please see both the image and video bellow for more info. Thank you.
Please note all this code is contained within side a "StackPanel", the intention is such that they can be copied and pasted multiple times.
Working Code outside a Flipper:
<Grid Height="89">
<Grid Width="77" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="7,3,0,2" Panel.ZIndex="2" Height="84">
<Ellipse Fill="{Binding Colour}" HorizontalAlignment="Left" Height="77" StrokeThickness="3" Stroke="#FF464646" Width="77" Effect="{DynamicResource MaterialDesignShadowDepth2}" />
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" Width="90" FontSize="{Binding FontSize}" Foreground="White" />
</Grid>
<UniformGrid Rows="2" Columns="1" Panel.ZIndex="3" Margin="89,18,72,0">
<TextBox TextWrapping="Wrap" Text="{Binding BrandName}" FontSize="24" Grid.ColumnSpan="1"/>
<Label Content="Brand Name" Grid.ColumnSpan="1" Grid.RowSpan="2" Margin="-2,-3,2,3"/>
</UniformGrid>
<Button Style="{StaticResource MaterialDesignFloatingActionMiniDarkButton}" HorizontalAlignment="Right" Panel.ZIndex="4" Content="{materialDesign:PackIcon DotsHorizontal}" Command="{x:Static materialDesign:Flipper.FlipCommand}" Margin="0,25,19,24"/>
<materialDesign:Card Margin="24,0,5,5" VerticalAlignment="Bottom" Height="72" Panel.ZIndex="-1" />
</Grid>
Broken Code, inside a Flipper:
<materialDesign:Flipper Visibility="{Binding IsVisible}" Background="#FFE89595" HorizontalAlignment="Stretch">
<materialDesign:Flipper.FrontContent>
Grid Height="89">
<Grid Width="77" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="7,3,0,2" Panel.ZIndex="2" Height="84">
<Ellipse Fill="{Binding Colour}" HorizontalAlignment="Left" Height="77" StrokeThickness="3" Stroke="#FF464646" Width="77" Effect="{DynamicResource MaterialDesignShadowDepth2}" />
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" Width="90" FontSize="{Binding FontSize}" Foreground="White" />
</Grid>
<UniformGrid Rows="2" Columns="1" Panel.ZIndex="3" Margin="89,18,72,0">
<TextBox TextWrapping="Wrap" Text="{Binding BrandName}" FontSize="24" Grid.ColumnSpan="1"/>
<Label Content="Brand Name" Grid.ColumnSpan="1" Grid.RowSpan="2" Margin="-2,-3,2,3"/>
</UniformGrid>
<Button Style="{StaticResource MaterialDesignFloatingActionMiniDarkButton}" HorizontalAlignment="Right" Panel.ZIndex="4" Content="{materialDesign:PackIcon DotsHorizontal}" Command="{x:Static materialDesign:Flipper.FlipCommand}" Margin="0,25,19,24"/>
<materialDesign:Card Margin="24,0,5,5" VerticalAlignment="Bottom" Height="72" Panel.ZIndex="-1" />
</Grid>
</materialDesign:Flipper.FrontContent>
<materialDesign:Flipper.BackContent>
<Grid Height="200" Background="{Binding BackColour}">
<Button Style="{StaticResource MaterialDesignFloatingActionMiniDarkButton}" Content="{materialDesign:PackIcon DotsHorizontal}" Command="{x:Static materialDesign:Flipper.FlipCommand}"/>
</Grid>
</materialDesign:Flipper.BackContent>
</materialDesign:Flipper>
Example Image of render
YouTube Video Demonstration - The one highlighted in red is flipper.
Thank you for any help.

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>

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>

Ispost back like functionality in WPF pages

I am building a WPF application which contains a large number of pages. I want to know whether there is any function which is similar to IsPostBack in Asp.Net. I just wanted to know is this the first time the specific page is loading. Thanks in advance.
xaml
<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>
If your page navigation is taking place via Frame, then attach to the Frame.Navigated event. If you provide more detail (some XAML and code) then we might be able to be more helpful...

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