I've created a WPF application. This has to have a red colored theme. So I set every color to a type of red, but the problem is all the buttons within the window start blinking when the window opens. The funny thing is they start all simultaneously but after a while they begin to diverge. When the form loses focus they all stop blinking. When a button is clicked, only that one keeps blinking. But when a "not button" control gains focus they all start blinking again.
I found that it could have to do something with the Focusable property, but changing it doesn't change anything. I also found a way to overwrite the default style but that doesn't solve the problem ether. Source
This is my XAML code:
<Grid x:Name="gServerSettings">
<Label x:Name="lTitle" Content="Server Settings" HorizontalAlignment="Center" Margin="182,0,0,166" VerticalAlignment="Center" Width="118" Foreground="#FFFF9999" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="16" FontWeight="Bold" Height="34"/>
<TextBox x:Name="tServer" Margin="72,39,10,0" TextWrapping="Wrap" Background="{x:Null}" Foreground="#FFFF9999" BorderBrush="#FFFF9999" SelectionBrush="#FFFF9999" BorderThickness="1" VerticalContentAlignment="Center" Height="24" VerticalAlignment="Top" TabIndex="0"/>
<Label x:Name="lServer" Content="Server" HorizontalAlignment="Left" Margin="10,39,0,0" VerticalAlignment="Top" Width="62" Foreground="#FFFF9999" Height="24" VerticalContentAlignment="Center"/>
<TextBox x:Name="tDatabase" Margin="72,68,10,0" TextWrapping="Wrap" Background="{x:Null}" Foreground="#FFFF9999" BorderBrush="#FFFF9999" SelectionBrush="#FFFF9999" BorderThickness="1" VerticalContentAlignment="Center" Height="24" VerticalAlignment="Top" TabIndex="1"/>
<Label x:Name="lDatabase" Content="Database" HorizontalAlignment="Left" Margin="10,68,0,0" VerticalAlignment="Top" Width="62" Foreground="#FFFF9999" VerticalContentAlignment="Center" Height="24"/>
<TextBox x:Name="tUsername" Margin="72,97,10,0" TextWrapping="Wrap" Background="{x:Null}" Foreground="#FFFF9999" BorderBrush="#FFFF9999" SelectionBrush="#FFFF9999" BorderThickness="1" VerticalContentAlignment="Center" Height="24" VerticalAlignment="Top" TabIndex="2"/>
<Label x:Name="lUsername" Content="Username" HorizontalAlignment="Left" Margin="10,97,0,0" VerticalAlignment="Top" Width="62" Foreground="#FFFF9999" VerticalContentAlignment="Center" Height="24"/>
<Label x:Name="lPassword" Content="Password" HorizontalAlignment="Left" Margin="10,126,0,0" VerticalAlignment="Top" Width="62" Foreground="#FFFF9999" VerticalContentAlignment="Center" Height="24"/>
<PasswordBox x:Name="tPassword" Margin="72,126,10,0" Background="{x:Null}" Foreground="#FFFF9999" BorderBrush="#FFFF9999" SelectionBrush="#FFFF9999" BorderThickness="1" VerticalContentAlignment="Center" Height="24" VerticalAlignment="Top" TabIndex="3"/>
<Button x:Name="bOK" Content="OK" HorizontalAlignment="Left" Margin="215,168,0,0" VerticalAlignment="Top" Width="75" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="#FFFF9999" BorderThickness="1" IsDefault="True" TabIndex="6"/>
<Button x:Name="bCancel" Content="Cancel" HorizontalAlignment="Left" Margin="135,168,0,0" VerticalAlignment="Top" Width="75" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="#FFFF9999" BorderThickness="1" IsDefault="True" TabIndex="5"/>
<Button x:Name="bTestConnection" Content="Test Connection" HorizontalAlignment="Left" Margin="10,168,0,0" VerticalAlignment="Top" Width="120" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="#FFFF9999" BorderThickness="1" IsDefault="True" TabIndex="4" IsHitTestVisible="False"/>
</Grid>
I don't do anything programmatically yet, so my .CS file is empty.
Does anybody know how to solve this problem?
You'd have to basically reimplement the button style and remove that storyboard. You can dump out the default button style with Expression Blend and modify it to your liking. There isn't really any other easy way to disable that storyboard.
Related
I need help with my WPF application. In the bottom of my window I have a canvas which is filled dynamically with groupboxes, which contain several userlements like buttons and gridviews.
The inserted content is outside my window and I want to access it with scrollbars but the scrollbars aren't adjusting so I can't access the elements.
How can I reach the content with the scrollbars?
Thanks for your help.
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" >
<Grid Height="Auto">
<GroupBox Header="Fleet Import" HorizontalAlignment="Left" Height="115" Margin="23,21,0,0" VerticalAlignment="Top" Width="419">
<StackPanel Margin="0,0,-67,0">
<StackPanel Orientation="Horizontal">
<Button x:Name="btnSelectProject" Content="Select Project" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="88" Height="23" Click="btnSelectProject_Click"/>
<TextBox Name="tbPath" Height="17" Width="283" Margin="10,10,0,0" />
</StackPanel>
<Button x:Name="bntConnectTia" Content="Connect to TIA" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="88" Height="23" Click="bntConnectTia_Click"/>
</StackPanel>
</GroupBox>
<GroupBox Header="Start update" HorizontalAlignment="Left" Height="115" Margin="498,21,0,0" VerticalAlignment="Top" Width="277">
<StackPanel Orientation="Horizontal">
<StackPanel>
<RadioButton Content="Maintanace" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="88" Height="23"/>
<RadioButton Content="Production" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="88" Height="23"/>
</StackPanel>
<StackPanel>
<Button Content="Start Update" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="88" Height="23" Click="Button_Click_2"/>
<Button Content="Cancel" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="88" Height="23"/>
</StackPanel>
</StackPanel>
</GroupBox>
<GroupBox Header="GroupBox" HorizontalAlignment="Left" Height="164" Margin="23,157,0,0" VerticalAlignment="Top" Width="752">
<TextBox HorizontalAlignment="Left" Height="128" TextWrapping="Wrap" Name="tbOutput" VerticalAlignment="Top" Width="742" Margin="0,0,-2,0"/>
</GroupBox>
<Canvas x:Name="canvasDevices" Margin="23,346,25,10" Height="Auto" />
<GroupBox Header="GroupBox" HorizontalAlignment="Left" Height="164" Margin="-393,337,0,-439" VerticalAlignment="Top" Width="752" Visibility="Hidden">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Button Content="Button" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="10,10,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/>
<Button Content="Button" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75"/>
</StackPanel>
<DataGrid Margin="20,10,20,0" RenderTransformOrigin="0.163,0.543" Height="88"/>
</StackPanel>
</GroupBox>
<Button Content="Button" HorizontalAlignment="Left" Margin="89,151,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_3"/>
</Grid>
</ScrollViewer>
GroupBox groupbox = new GroupBox();
groupbox.Header = deviceName;
groupbox.Name = deviceName;
groupbox.Width = 742;
groupbox.Height = 250;
stackPanelV.Children.Add(stackPanelH);
stackPanelV.Children.Add(dgDevice);
groupbox.Content = stackPanelV;
Canvas.SetTop(groupbox,0);
canvasDevices.Children.Add(groupbox);
Your items get out the canvas bounds, canvas is not resized and ScrollView not applied.
By the way I dont recommend you using canvas for that prupose.
There is plenty of other layouts that will give you a better result such as StackPanel or WrapPanel, and if you give to WrapPanel a width it will nicely rearrange your items.
I have 2 textblocks on my form. I need to have vertical scrollbars in each of them. Due to some reason, I am not able to get the scrollbars on both. Kindly provide me with some idea.
<Grid>
<Button Content="COMPARE" HorizontalAlignment="Left" Margin="216,30,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
<TextBox x:Name="TextBox1" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,69,0,0" TextWrapping="Wrap" RenderTransformOrigin="-1.351,-2.164" Height="242" Width="226" Loaded="TextBox1_Loaded" />
<ScrollViewer>
<TextBlock x:Name="TextBlock1" HorizontalAlignment="Left" Margin="10,69,0,0" TextWrapping="Wrap" VerticalAlignment="Top" RenderTransformOrigin="-1.351,-2.164" Height="242" Width="226" Loaded="TextBlock1_Loaded" />
</ScrollViewer>
<TextBox x:Name="TextBox2" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Left" Margin="258,69,0,0" TextWrapping="Wrap" VerticalAlignment="Top" RenderTransformOrigin="-1.351,-2.164" Height="242" Width="226" Loaded="TextBox2_Loaded"/>
<ScrollViewer>
<TextBlock x:Name="TextBlock2" HorizontalAlignment="Left" Margin="258,69,0,0" TextWrapping="Wrap" VerticalAlignment="Top" RenderTransformOrigin="-1.351,-2.164" Height="242" Width="226" Loaded="TextBlock2_Loaded_1"/>
</ScrollViewer>
<Button Content="EDIT" HorizontalAlignment="Left" Margin="409,30,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
<Button Content="HOME" HorizontalAlignment="Left" Margin="21,26,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="0.23,0.986" Click="Button_Click_2"/>
</Grid>
Try to check this out:
1. XAML Code:
<ScrollViewer Grid.Column="0" Grid.Row="0">
<TextBlock x:Name="ATextBlock" ></TextBlock></ScrollViewer>
<ScrollViewer Grid.Row="0" Grid.Column="1" >
<TextBlock x:Name="BtTextBlock" ></TextBlock></ScrollViewer>
the problem was; the Height definition on the TextBlock. Just remove it and that is.
regards.,
To show vertical scroll bar on a TextBox when needed you can use this XAML
<TextBox .... VerticalScrollBarVisibility="Auto" />
ScrollBar will apear when text does not fit the original space given to controll.
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.
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 .
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