I am new into WPF and i am developing a app with different images, textbox, etc. The problem is here on my screen it all looks ok according to the size of the window with the properties ive set on the window loaded:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Width = System.Windows.SystemParameters.PrimaryScreenWidth;
Height = System.Windows.SystemParameters.PrimaryScreenHeight;
}
When using the application on my screen it looks like this:
But when using it on a tablet i cant see the Calendar neither the text that says "Fecha nacimiento". Here is the WPF code i am using:
<Window x:Class="BiometricoRegistro.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="RegistrarCliente" Height="978" Width="1600" Loaded="Window_Loaded" WindowState="Maximized">
<Grid>
<Grid.Background>
<ImageBrush ImageSource="Imagenes\home_bg.jpg"/>
</Grid.Background>
<TextBox x:Name="txtbRut" HorizontalAlignment="Left" Height="51" TextWrapping="Wrap" BorderBrush="Transparent" VerticalAlignment="Top" Width="379" Margin="30,230,0,0" FontSize="35" FontWeight="Bold" PreviewTextInput="txtbRut_PreviewTextInput">
<TextBox.Background>
<ImageBrush ImageSource="Imagenes\input.png"/>
</TextBox.Background>
</TextBox>
<TextBox x:Name="txtbRutVer" HorizontalAlignment="Left" Height="51" TextWrapping="Wrap" BorderBrush="Transparent" VerticalAlignment="Top" Width="74" Margin="430,230,0,0" FontSize="35" FontWeight="Bold" TextAlignment="Center">
<TextBox.Background>
<ImageBrush ImageSource="Imagenes\input.png"/>
</TextBox.Background>
</TextBox>
<TextBox x:Name="txtbNombre" HorizontalAlignment="Left" Height="51" TextWrapping="Wrap" BorderBrush="Transparent" VerticalAlignment="Top" Width="474" Margin="30,330,0,0" FontSize="35" FontWeight="Bold">
<TextBox.Background>
<ImageBrush ImageSource="Imagenes\input.png"/>
</TextBox.Background>
</TextBox>
<TextBox x:Name="txtbApellido" HorizontalAlignment="Left" Height="51" TextWrapping="Wrap" BorderBrush="Transparent" VerticalAlignment="Top" Width="474" Margin="30,430,0,0" FontSize="35" FontWeight="Bold">
<TextBox.Background>
<ImageBrush ImageSource="Imagenes\input.png"/>
</TextBox.Background>
</TextBox>
<TextBox x:Name="txtbEmail" HorizontalAlignment="Left" Height="51" TextWrapping="Wrap" BorderBrush="Transparent" VerticalAlignment="Top" Width="474" Margin="30,530,0,0" FontSize="35" FontWeight="Bold">
<TextBox.Background>
<ImageBrush ImageSource="Imagenes\input.png"/>
</TextBox.Background>
</TextBox>
<Calendar x:Name="calendar" HorizontalAlignment="Left" Height="170" VerticalAlignment="Top" Width="260" Margin="0,720,0,57"/>
<Button x:Name="btnRegistrar" Content="Registrar" HorizontalAlignment="Center" Height="118" VerticalAlignment="Center" Width="296" Margin="775,0,221,100" Click="btnRegistrar_Click"/>
<ComboBox x:Name="cbPorcentaje" HorizontalAlignment="Left" Height="40" Margin="30,630,0,0" VerticalAlignment="Top" Width="230" HorizontalContentAlignment="Center" FontSize="35">
<ComboBoxItem Content="A" FontSize="35"></ComboBoxItem>
<ComboBoxItem Content="B" FontSize="35"></ComboBoxItem>
<ComboBoxItem Content="C" FontSize="35"></ComboBoxItem>
</ComboBox>
<TextBlock HorizontalAlignment="Left" Height="37" Margin="30,176,0,0" TextWrapping="Wrap" Text="Rut cliente" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
<TextBlock HorizontalAlignment="Left" Height="37" Margin="30,286,0,0" TextWrapping="Wrap" Text="Nombres cliente" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
<TextBlock HorizontalAlignment="Left" Height="37" Margin="30,386,0,0" TextWrapping="Wrap" Text="Apellidos cliente" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
<TextBlock HorizontalAlignment="Left" Height="37" Margin="30,486,0,0" TextWrapping="Wrap" Text="Email cliente" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
<TextBlock HorizontalAlignment="Left" Height="37" Margin="30,586,0,0" TextWrapping="Wrap" Text="Tipo Descuento" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
<TextBlock HorizontalAlignment="Left" Height="37" Margin="30,678,0,230" TextWrapping="Wrap" Text="Fecha nacimiento" VerticalAlignment="Top" Width="474" FontFamily="/BiometricoRegistro;component/Fonts/#Alex Brush" FontSize="36" Foreground="White"/>
<TextBlock x:Name="txtResult" HorizontalAlignment="Left" Height="64" Margin="501,0,0,57" TextWrapping="Wrap" Text="" VerticalAlignment="Bottom" Width="823" FontSize="46" Foreground="Red" FontFamily="PMingLiU-ExtB"/>
</Grid>
</Window>
Always use appropriate panels . I would prefer Dock and stackpanel with splitters.
assign System.Windows.Window.SizeToContent to System.Windows.SizeToContent.WidthAndHeight.
Use Resource Dictonary for consistency of margins and other values
I would not prefer to use Absolute positions. decide your margin values depending on your content .
Related
I´m working on a Windows Phone 8.1 c# app.
I´m trying to acces a textbox that is inside a tab page of a Hub. But whatever i do i can´t acces the textbox in the MainPage.xaml.cs code. Can anyone tell me why?
Here is my XAML code:
<Grid>
<Hub x:Name="Hub" Header="My Buddy!" Background="#FF303030">
<HubSection Tag="0" x:Name="HubSelection" Header="Hoofdscherm">
<DataTemplate>
<Grid>
<Button x:Name="btnAgenda" Content="Agenda" HorizontalAlignment="Left" Margin="20,17,0,0" VerticalAlignment="Top" Height="140" Width="140" RenderTransformOrigin="0.5,0.5" BorderBrush="White" Background="#FFD13535" Foreground="White" Click="btnAgenda_Click"/>
<Button x:Name="btnTaken" Content="Taken" HorizontalAlignment="Right" Margin="0,17,20,0" VerticalAlignment="Top" Height="140" Width="140" RenderTransformOrigin="0.5,0.5" BorderBrush="White" Background="#FFD13535" Foreground="White" Click="btnTaken_Click"/>
<Button x:Name="btnNieuweAfspraak" Content="Nieuwe afspraak" HorizontalAlignment="Left" Margin="20,161,0,0" VerticalAlignment="Top" Height="140" Width="140" RenderTransformOrigin="0.5,0.5" BorderBrush="White" Background="#FFD13535" Foreground="White" Click="btnNieuweAfspraak_Click"/>
<Button x:Name="btnNieuweTaak" Content="Nieuwe taak" HorizontalAlignment="Right" Margin="0,161,20,0" VerticalAlignment="Top" Height="140" Width="140" RenderTransformOrigin="0.5,0.5" BorderBrush="White" Background="#FFD13535" Foreground="White" Click="btnNieuweTaak_Click"/>
</Grid>
</DataTemplate>
</HubSection>
<HubSection Tag="1" Header="Agenda">
<DataTemplate>
<Grid>
<AppBarButton HorizontalAlignment="Left" Icon="Add" Label="Nieuwe afspraak" Margin="6,419,-2,0" VerticalAlignment="Top" Height="81" Width="337" Click="AppBarButton_Click"/>
</Grid>
</DataTemplate>
</HubSection>
<HubSection Tag="2" Header="Taken">
<DataTemplate>
<Grid>
<AppBarButton HorizontalAlignment="Left" Icon="Add" Label="Nieuwe taak" Margin="6,419,-2,0" VerticalAlignment="Top" Height="81" Width="337" Click="AppBarButton_Click_1" FontFamily="Global User Interface"/>
</Grid>
</DataTemplate>
</HubSection>
<HubSection Tag="3" x:Name="NewAfspraak" Header="Nieuwe afspraak">
<DataTemplate>
<Grid>
<TextBox x:Name="AfspraakBox" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="321" Height="47" PlaceholderText="Naam afspraak" TextChanged="AfspraakBox_TextChanged" IsColorFontEnabled="False"/>
<DatePicker x:Name="DatumAfspraak" HorizontalAlignment="Left" Margin="10,52,0,0" VerticalAlignment="Top" Height="55" Width="157"/>
<TimePicker x:Name="BegintijdAfspraak" HorizontalAlignment="Left" Margin="172,52,0,0" VerticalAlignment="Top" Height="53" Width="159"/>
<TextBox x:Name="tbLocatieAfspraak" HorizontalAlignment="Left" Margin="10,106,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="321" PlaceholderText="Locatie" Height="42"/>
<TextBox HorizontalAlignment="Left" Margin="10,165,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="255" Width="321" PlaceholderText="Omschrijving"/>
<Button x:Name="btnAfspraakOpslaan1" Content="Opslaan" HorizontalAlignment="Left" Margin="172,436,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Width="159" Height="63" Click="btnAfspraakOpslaan1_Click"/>
<Button x:Name="btnAfspraakOpslaan" Content="Annuleren" HorizontalAlignment="Left" Margin="10,436,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Width="157" Height="63" Click="btnAfspraakAnnuleren_Click"/>
</Grid>
</DataTemplate>
</HubSection>
<HubSection Tag="4" Header="Nieuwe taak">
<DataTemplate>
<Grid>
<TextBox x:Name="TbNaamTaak" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="321" Height="47" PlaceholderText="Naam taak"/>
<TextBox x:Name="tbTaakOmschrijving" HorizontalAlignment="Left" Margin="10,168,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="321" Height="254" PlaceholderText="Omschrijving"/>
<TextBlock HorizontalAlignment="Left" Margin="172,62,0,0" TextWrapping="Wrap" Text="Eindtijd:" VerticalAlignment="Top" Height="14" Width="54"/>
<TextBlock HorizontalAlignment="Left" Margin="10,62,0,0" TextWrapping="Wrap" Text="Begintijd:" VerticalAlignment="Top" Height="14" Width="98"/>
<TimePicker x:Name="BegintijdNieuweTaak" HorizontalAlignment="Left" Margin="10,71,0,0" VerticalAlignment="Top" Width="157" Height="55" ToolTipService.ToolTip="Selecteer een begintijd:" FontFamily="Global User Interface"/>
<TimePicker x:Name="EindtijdNieuweTaak" HorizontalAlignment="Left" Margin="172,71,0,0" VerticalAlignment="Top" Width="159" Height="53" ToolTipService.ToolTip="Selecteer een eindtijd:"/>
<Button x:Name="btnTaakOpslaan" Content="Opslaan" HorizontalAlignment="Left" Margin="172,436,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Width="159" Height="63" FontFamily="Global User Interface" Click="btnTaakOpslaan_Click"/>
<Button Content="Annuleren" HorizontalAlignment="Left" Margin="10,436,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Width="157" Height="63" Click="btnTaakAnnuleren" FontFamily="Global User Interface"/>
<DatePicker x:Name="DatumNieuweTaak" HorizontalAlignment="Left" Margin="10,114,0,0" VerticalAlignment="Top" Height="81" Width="321" FontFamily="Global User Interface"/>
</Grid>
</DataTemplate>
</HubSection>
</Hub>
</Grid>
And my MainPage.xaml.cs code:
private void btnTaken_Click(object sender, RoutedEventArgs e)
{
String Test = AfspraakBox.text;
Hub.ScrollToSection(Hub.Sections[2]);
}
The error that i'm getting is:
AfspraakBox does not exist in the current context.
I'm pritty sure it has something to do with the Hubs. Because in a new project without a Hub it just works fine. But i just can't figure out why and how to fix it.
You can't access a XAML control inside of a DataTemplate. That's a problem of HubSections. It uses DataTemplate, unlike PivotItem.
How to make this code scroll'able?
I've tried this solution but it won't work: Need to scroll one WPF Grid
My XAML (Grid named Photos has to scroll):
<Grid Height="533" VerticalAlignment="Bottom">
<TextBox x:Name="siteAdressTextBox" HorizontalAlignment="Left" Height="23" Margin="10,10,0,0" TextWrapping="Wrap" Text="http://www.etrapez.pl/" VerticalAlignment="Top" Width="215"/>
<Button x:Name="sendWebRequestButton" Content="Wyślij zapytanie" HorizontalAlignment="Left" Margin="10,38,0,0" VerticalAlignment="Top" Width="107" Click="webRequest"/>
<Button Content="Pobierz wszystko" HorizontalAlignment="Left" Margin="122,38,0,0" VerticalAlignment="Top" Width="103" Click="downThemAll"/>
<ScrollViewer HorizontalAlignment="Left" Height="460" Margin="10,63,0,0" VerticalAlignment="Top" Width="1000" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible" CanContentScroll="True">
<Grid x:Name="Photos" HorizontalAlignment="Left" Height="460" VerticalAlignment="Top" Width="1000" ShowGridLines="False" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Visible" />
</ScrollViewer>
<TextBox Name="InfoBoxLabel" IsReadOnly="True" VerticalScrollBarVisibility="Auto" HorizontalAlignment="Left" Height="48" Margin="230,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="300"/>
</Grid>
try this
<Grid Height="533" VerticalAlignment="Bottom">
<TextBox x:Name="siteAdressTextBox" HorizontalAlignment="Left" Height="23" Margin="10,10,0,0" TextWrapping="Wrap" Text="http://www.etrapez.pl/" VerticalAlignment="Top" Width="215"/>
<Button x:Name="sendWebRequestButton" Content="Wyślij zapytanie" HorizontalAlignment="Left" Margin="10,38,0,0" VerticalAlignment="Top" Width="107"/>
<Button Content="Pobierz wszystko" HorizontalAlignment="Left" Margin="122,38,0,0" VerticalAlignment="Top" Width="103" />
<ScrollViewer HorizontalAlignment="Left" Height="460" Margin="10,63,0,0" VerticalAlignment="Top" Width="1000" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">
<Grid x:Name="Photos" ShowGridLines="False">
<TextBlock TextWrapping="Wrap" Text="text here"/>
</Grid>
</ScrollViewer>
<TextBox Name="InfoBoxLabel" IsReadOnly="True" VerticalScrollBarVisibility="Auto" HorizontalAlignment="Left" Height="48" Margin="230,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="300"/>
</Grid>
Output will be http://prntscr.com/3w0cr9
I am getting this error when I go to open my WPF window and I have no idea what created the error or how to get rid of it. The error is highlighting and pointing to </Border> at the bottom.
'Initialization of 'Outlook_Add_In_Test.WPFExiEvent' threw an exception.' Line number '91' and line position '11'.
My WPF Code:
<Controls:MetroWindow x:Class="Outlook_Add_In_Test.WPFExiEvent"
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:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:System="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d" d:DesignWidth="550" MaxHeight="640" MaxWidth="550" Title="Search for an Existing Event" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Height="340" HorizontalAlignment="Center" VerticalAlignment="Center">
<Controls:MetroWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="Theme/Test.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
<ResourceDictionary Source="Theme/FlatButton.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Controls:MetroWindow.Resources>
<Border BorderBrush="Black" BorderThickness="1">
<Grid Margin="0,0,0,-1">
<Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="1" Margin="6,108,0,0" VerticalAlignment="Top" Width="524" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="-1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
</Border>
<Image x:Name="ImgDefactoLogo" HorizontalAlignment="Left" Height="36" Margin="10,10,0,0" VerticalAlignment="Top" Width="43" Source="Images/DeFactoERP.ico"/>
<Image x:Name="ImgAttachmentType" HorizontalAlignment="Left" Margin="65,10,0,0" Width="32" RenderTransformOrigin="0.143,0.778" Height="36" VerticalAlignment="Top"/>
<Label Content="Search for an Existing Event" HorizontalAlignment="Left" Height="36" Margin="97,19,0,0" VerticalAlignment="Top" Width="259" FontSize="16" FontFamily="Arial" FontWeight="Bold"/>
<TextBlock x:Name="LblInfo" HorizontalAlignment="Left" Height="47" Margin="10,60,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="524" FontSize="15" FontFamily="Arial" Text="Please search for an existing event in your De Facto ERP system that you want to use for adding the attachment to."/>
<Label Content="Event No:" HorizontalAlignment="Left" Height="43" Margin="7,126,0,0" VerticalAlignment="Top" Width="112" FontSize="16" FontFamily="Arial" FontWeight="Bold" Foreground="Black"/>
<Label Content="Event Subject:" HorizontalAlignment="Left" Height="43" Margin="7,164,0,0" VerticalAlignment="Top" Width="119" FontSize="16" FontFamily="Arial" FontWeight="Bold"/>
<TextBox x:Name="TxtEventNo" HorizontalAlignment="Left" Height="33" Margin="151,126,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="200" ToolTip="Enter Event Number..." KeyDown="TxtEventNo_KeyDown" TextChanged="TxtEventNo_TextChanged"/>
<TextBox x:Name="TxtSubject" HorizontalAlignment="Left" Height="33" Margin="151,164,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="200" KeyDown="TxtSubject_KeyDown" TextChanged="TxtSubject_TextChanged"/>
<Label Content="Event Customer:" HorizontalAlignment="Left" Height="43" Margin="7,202,0,0" VerticalAlignment="Top" Width="142" FontSize="16" FontFamily="Arial" FontWeight="Bold"/>
<TextBox x:Name="TxtCust" HorizontalAlignment="Left" Height="33" Margin="342,22,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="200" ToolTip="Enter Event Number..." TextChanged="TxtCust_TextChanged" KeyDown="TxtCust_KeyDown"/>
<CheckBox x:Name="ChkActive" Content="Active Events Only" IsChecked="True" HorizontalAlignment="Left" Height="19" Margin="13,238,0,0" VerticalAlignment="Top" Width="124" Checked="ChkActive_Checked" Unchecked="ChkActive_UnChecked"/>
<Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="1" Margin="7,267,0,0" VerticalAlignment="Top" Width="524" Opacity="0.2" RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleY="-1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Border.RenderTransform>
</Border>
<Button x:Name="BtnSearch" Click="BtnSearch_Click" HorizontalAlignment="Left" Width="100" Background="#FF333333" Foreground="White" FontWeight="Normal" FontSize="14" Margin="422,162,0,0" Height="37" VerticalAlignment="Top">
<TextBlock Text="SEARCH" VerticalAlignment="Center" TextAlignment="Right" FontSize="14" Width="73" Height="15" FontFamily="Arial" Foreground="White" RenderTransformOrigin="0.684,0.261"/>
</Button>
<ListBox x:Name="LstEvents" HorizontalAlignment="Left" Margin="10,300,0,14" Width="524" BorderBrush="Black" BorderThickness="2,2,1,1">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Height="97">
<Canvas x:Name="EventItem" HorizontalAlignment="Left" Height="97" VerticalAlignment="Top" Width="502" Background="{Binding LBackground}" Margin="0,0,0,-21">
<Label Content="Event:" HorizontalAlignment="Left" Height="33" VerticalAlignment="Top" Width="97" FontWeight="Bold" FontSize="14" Canvas.Left="1" Canvas.Top="2"/>
<Label Content="Subject:" HorizontalAlignment="Left" Height="33" VerticalAlignment="Top" Width="97" FontWeight="Bold" FontSize="14" Canvas.Left="1" Canvas.Top="23"/>
<Label Content="Body:" HorizontalAlignment="Left" Height="33" VerticalAlignment="Top" Width="97" FontWeight="Bold" FontSize="14" Canvas.Left="1" Canvas.Top="47"/>
<Button x:Name="BtnSelectEvent" Content="Select" HorizontalAlignment="Left" Height="34" VerticalAlignment="Top" Width="74" Background="#FF333333" Foreground="White" FontWeight="Normal" FontSize="14" Canvas.Left="418" Canvas.Top="33" Click="BtnSelectEvent_Click"/>
<Label Content="{Binding Lsubject}" Height="25" Canvas.Left="80" Canvas.Top="3" Width="333"/>
<Label Content="{Binding Lbody}" Height="25" Canvas.Left="80" Canvas.Top="25" Width="333"/>
<Label Content="{Binding Lbody}" Height="25" Canvas.Left="80" Canvas.Top="49" Width="333"/>
<Label Content="Customer:" HorizontalAlignment="Left" Height="33" VerticalAlignment="Top" Width="97" FontWeight="Bold" FontSize="14" Canvas.Left="1" Canvas.Top="69"/>
<Label Content="{Binding LCust}" Height="25" Canvas.Left="80" Canvas.Top="71" Width="333"/>
</Canvas>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Label x:Name="LblResultsReturned" Content="" HorizontalAlignment="Left" Height="27" Margin="37,273,0,-19" VerticalAlignment="Top" Width="492" FontWeight="Bold" FontFamily="Arial" FontSize="11" />
<Label x:Name="LblEventCount" Content="" HorizontalAlignment="Left" Height="27" Margin="10,273,0,-19" VerticalAlignment="Top" FontWeight="Bold" FontFamily="Arial" FontSize="11" />
<Image x:Name="ImgSearch" HorizontalAlignment="Left" Height="28" Margin="431,171,0,0" VerticalAlignment="Top" Width="22" Source="Images/Icon-Search-Big-White.png" RenderTransformOrigin="0.419,1.269"/>
<Label x:Name="LblError" Content="" HorizontalAlignment="Left" Height="27" Margin="199,273,0,-19" VerticalAlignment="Top" Width="330" FontWeight="Bold" FontFamily="Arial" FontSize="11" />
<Controls:ProgressRing x:Name="LoadingRing" IsActive="False" Margin="356,153,126,0" VerticalAlignment="Top"/>
</Grid>
</Border>
</Controls:MetroWindow>
Going on what you said in the comments it seems it is linked to the MahApps Metro Theme.
Take a look at this: https://github.com/MahApps/MahApps.Metro/issues/582
If you have referenced the Windows Interactivity dll try removing it.
In future remember to check the InnerException like SLaks said. You can learn a lot more from this and give you more to work on.
Maybe for someone it will be useful. Today I ran into the same problem:
"XamlParseException on window initialization" in project with nuget reference to MahApp.
I tryed reinstaling packages, removing references - nothithing helped.
In may case the problem was in app.config. When I removed these lines, problem disappeared:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Does anyone know why this happens?
I think you just imported the wrong dll (NET40). Try to import the latest MahApps.Metro.dll (NET45).
It worked for me.
For me, I downgraded the MahApps.Metro to version 1.6.4 and the error has gone
I was using version 1.6.5 before
And the version of MahApps.Metro.Resources is 0.6.1
I started learning Windows 8 app development (I'm a beginner) and I'm making an app where I want to add its tile icon. When I press the window key, then our program exe icon shows as default, but I want to add my own icon. How do I do this?
How do I add an image in this sample code?
<Page
x:Class="Calculator.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Calculator"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="Tomato">
<Button x:Name="btn0" Content="0" HorizontalAlignment="Left" Height="64" Margin="458,459,0,0" VerticalAlignment="Top" Width="120" FontSize="36" FontWeight="Bold" Click="showbtn"/>
<Button x:Name="btn1" Content="1" HorizontalAlignment="Left" Height="64" Margin="458,390,0,0" VerticalAlignment="Top" Width="120" FontSize="36" FontWeight="Bold" Click="showbtn"/>
<Button x:Name="btn2" Content="2" HorizontalAlignment="Left" Height="64" Margin="583,390,0,0" VerticalAlignment="Top" Width="120" FontSize="36" FontWeight="Bold" Click="showbtn"/>
<Button x:Name="btn3" Content="3" HorizontalAlignment="Left" Height="64" Margin="708,390,0,0" VerticalAlignment="Top" Width="120" FontSize="36" FontWeight="Bold" Click="showbtn"/>
<Button x:Name="btn4" Content="4" HorizontalAlignment="Left" Height="64" Margin="458,321,0,0" VerticalAlignment="Top" Width="120" FontSize="36" FontWeight="Bold" Click="showbtn"/>
<Button x:Name="btn5" Content="5" HorizontalAlignment="Left" Height="64" Margin="578,321,0,0" VerticalAlignment="Top" Width="120" FontSize="36" FontWeight="Bold" Click="showbtn"/>
<Button x:Name="btn6" Content="6" HorizontalAlignment="Left" Height="64" Margin="708,321,0,0" VerticalAlignment="Top" Width="120" FontSize="36" FontWeight="Bold" Click="showbtn"/>
<Button x:Name="btn7" Content="7" HorizontalAlignment="Left" Height="64" Margin="458,252,0,0" VerticalAlignment="Top" Width="120" FontSize="36" FontWeight="Bold" Click="showbtn"/>
<Button x:Name="btn8" Content="8" HorizontalAlignment="Left" Height="64" Margin="583,252,0,0" VerticalAlignment="Top" Width="120" FontSize="36" FontWeight="Bold" Click="showbtn"/>
<Button x:Name="btn9" Content="9" HorizontalAlignment="Left" Height="64" Margin="708,252,0,0" VerticalAlignment="Top" Width="120" FontSize="36" FontWeight="Bold" Click="showbtn"/>
<TextBox x:Name="Output" HorizontalAlignment="Left" Height="68" Margin="458,179,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="370" FontSize="24"/>
</Grid>
</Page>
You can replace the default tile image with your own logo image with the path in the package .appxmanifest
You can get the guidelines over here http://msdn.microsoft.com/en-us/library/windows/apps/hh465437.aspx
Hope it will solve your problem
It's a very stupid question :)
Which property sets vertical scroll?
Developing Windows Phone 7 app, I switched off this property, and I don't understand, how I did it :)
I use ComboBox, and when I create project, I can scroll text in ComboBox, but now I can't
You need to include all the items inside the Scrollviewer, as in pivot page, we can't make the content scroller without scroll viewer.
Here is the sample content.
<ScrollViewer HorizontalAlignment="Left" VerticalAlignment="Top" Height="647" Margin="0" Grid.Row="1">
<Grid x:Name="ContentPanel" Margin="0,0,0,24" Width="480" Height="1470" Grid.Row="1">
<Image x:Name="ImgProcess" Source="/GoogTaxi;component/images/loading2.jpg" Visibility="Collapsed" Stretch="None" Opacity="0.60" VerticalAlignment="Top" />
<TextBlock x:Name="tbkCompanyName" TextWrapping="Wrap" Text="Company Name" Margin="20,20,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtCompanyName" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,47,8,0"/>
<TextBlock x:Name="tbkAddress" TextWrapping="Wrap" Text="Address" Margin="20,120,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtAddress" AcceptsReturn="True" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,147,8,336" VerticalScrollBarVisibility="Auto" Height="131"/>
<TextBlock x:Name="tbkEmailId" TextWrapping="Wrap" Text="Email Id" Margin="20,279,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtEmailId" IsEnabled="False" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,306,8,0" d:LayoutOverrides="VerticalAlignment"/>
<TextBlock x:Name="tbkWebsite" TextWrapping="Wrap" Margin="20,379,0,0" VerticalAlignment="Top"><Run Text="Website"/><LineBreak/><Run/></TextBlock>
<TextBox x:Name="txtWebsite" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,406,8,0" d:LayoutOverrides="VerticalAlignment"/>
<TextBlock x:Name="tbkPhone" TextWrapping="Wrap" Text="Phone" Margin="20,479,0,0" VerticalAlignment="Top" d:LayoutOverrides="VerticalAlignment"/>
<TextBox x:Name="txtPhone" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,506,8,0"/>
<TextBlock x:Name="tbkCity" TextWrapping="Wrap" Margin="20,579,0,0" VerticalAlignment="Top" Text="City"/>
<TextBox x:Name="txtCity" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,606,8,0"/>
<TextBlock x:Name="tbkState" TextWrapping="Wrap" Text="State" Margin="20,676,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtState" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,704,8,0"/>
<TextBlock x:Name="tblCountry" TextWrapping="Wrap" Text="Country" Margin="20,780,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtCountry" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,806,8,0"/>
<TextBlock x:Name="tbkCompany_logo" Visibility="Collapsed" TextWrapping="Wrap" Text="Contact Person" Margin="20,0,0,42.602" VerticalAlignment="Top" d:IsHidden="True"/>
<TextBox x:Name="txtCompany_logo" Visibility="Collapsed" TextWrapping="Wrap" Margin="8,0,8,-29.305" VerticalAlignment="Top" d:IsHidden="True"/>
<TextBlock x:Name="tbkContactPerson" TextWrapping="Wrap" Text="Contact Person" Margin="20,879,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtContactPerson" TextWrapping="Wrap" Margin="8,908,8,0" VerticalAlignment="Top"/>
<TextBlock x:Name="tbkContactPhone" TextWrapping="Wrap" Text="Contact Person Phone" Margin="20,982,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtContactPhone" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,1005,8,0"/>
<TextBlock x:Name="tbkContactEmail" TextWrapping="Wrap" Text="Contact person Email ID" Margin="20,1079,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtContactEmail" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,1106,8,0"/>
<TextBlock x:Name="tbkMerchantId" TextWrapping="Wrap" Text="Google Merchant Id" Margin="20,1180,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtMerchantId" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,1209,8,0" IsEnabled="False" />
<TextBlock x:Name="tbkMerchantKey" TextWrapping="Wrap" Text="Google Merchant Key" Margin="20,1282,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="txtMerchantKey" TextWrapping="Wrap" VerticalAlignment="Top" Margin="8,1310,8,0" IsEnabled="False" />
<Button x:Name="btnsave" Content="Save" Margin="33,1390,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Click="btnsave_Click" />
<Button x:Name="btnCancel" Content="Cancel" Margin="0,1390,33,0" VerticalAlignment="Top" HorizontalAlignment="Right" d:LayoutOverrides="HorizontalAlignment" Click="btnCancel_Click" />
</Grid>
</ScrollViewer>
There is no scroll functionality inside PivotItem. You should use ScrollViewer control to get it by your own.
In a pivot control, if the content is overflowing the vertical page then there should be default "vertical" scrolling available to you.
I had a similar control with "list box" bounded to property. Having the list box should automatically allow you to scroll.
Don't add a scrollviewer over the stack panel as it would make the scrolling enabled for each list item which you don't want.
<controls:PivotItem Header="all authors" Foreground="#FF0C388A">
<Grid>
<ListBox Margin="0,0,-12,0" ItemsSource="{Binding AllAuthorsList}" Foreground="#FF0C388A">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Width="432" Height="Auto">
<TextBlock Tap="TextBlockAuthor_Tap" Text="{Binding}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" Foreground="#FF0C388A"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</controls:PivotItem>