Trying to figure out why my silverlight app suddenly just displays nothing (right click shows silverlight) when i run it and also nothing when i open the html-document created by VS2010?
This happened all of a sudden and i have no idea why. I have even deleted all my code behind except for an event.
Silverlight code:
<UserControl x:Class="Test.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"
d:DesignHeight="395" d:DesignWidth="399"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
<Grid x:Name="LayoutRoot" Background="White">
<Image Height="96"
HorizontalAlignment="Left"
Margin="55,34,0,0"
Name="image1"
Stretch="Fill"
VerticalAlignment="Top"
Width="71" />
<Image Height="96"
HorizontalAlignment="Left"
Margin="155,34,0,0"
Name="image2"
Stretch="Fill"
VerticalAlignment="Top"
Width="71" />
<Image Height="96"
HorizontalAlignment="Left"
Margin="257,34,0,0"
Name="image3"
Stretch="Fill"
VerticalAlignment="Top"
Width="71" />
<Image Height="96"
HorizontalAlignment="Left"
Margin="55,270,0,0"
Name="image4"
Stretch="Fill"
VerticalAlignment="Top"
Width="71" />
<Image Height="96"
HorizontalAlignment="Left"
Margin="155,270,0,0"
Name="image5"
Stretch="Fill"
VerticalAlignment="Top"
Width="71" />
<Image Height="96"
HorizontalAlignment="Left"
Margin="257,270,0,0"
Name="image6"
Stretch="Fill"
VerticalAlignment="Top"
Width="71" />
<Button Content="Draw/Next"
Height="23"
HorizontalAlignment="Left"
Margin="155,159,0,0"
Name="button1"
VerticalAlignment="Top"
Width="71" />
<sdk:Label Height="43"
HorizontalAlignment="Left"
Margin="33,173,0,0"
Name="label1"
VerticalAlignment="Top"
Width="44"
Content=""
FontSize="32" />
<sdk:Label FontSize="32"
Height="43"
HorizontalAlignment="Right"
Margin="0,173,52,0"
Name="label2"
VerticalAlignment="Top"
Width="44"
Content="" />
<Button Content="Restart"
Height="23"
HorizontalAlignment="Left"
Margin="155,217,0,0"
Name="button2"
VerticalAlignment="Top"
Width="71"
Click="button2_Click" />
</Grid>
</UserControl>
Code behind:
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
private void button2_Click(object sender, RoutedEventArgs e)
{
}
}
Resolved after deleting all contents and recreating them again. Very strange behaviour.
Related
Im trying to create a progress bar for one of my computer configuration scripts and I'd like to avoid adding a button or some kind of trigger to the GUI,
The script is powershell and for the GUI XAML:
<Window x:Name="BackUp_MAINWINDOW" x:Class="ProgressBarTest.MainWindow"
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"
xmlns:local="clr-namespace:ProgressBarTest"
mc:Ignorable="d"
Title="88%" Height="110" Width="510" Icon="C:\Users\rsosa012\Documents\Scripts\Powershell\ICOs\PwC.ico" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen" Top="0" FontFamily="Georgia" Margin="0,-1,0,0" FontSize="11" SnapsToDevicePixels="True" BorderThickness="0">
<Window.TaskbarItemInfo>
<TaskbarItemInfo Description="Progress" ProgressState="Indeterminate" ProgressValue="50"/>
</Window.TaskbarItemInfo>
<Grid>
<ProgressBar HorizontalAlignment="Left" Height="17" Margin="10,44,0,0" VerticalAlignment="Top" Width="410" Value="50" Opacity="0.6"/>
<Image HorizontalAlignment="Left" Height="50" Margin="435,10,0,0" VerticalAlignment="Top" Width="50" Source="C:\Users\rsosa012\Documents\Scripts\Powershell\ICOs\PwC.ico"/>
<Label Content="Name: " HorizontalAlignment="Left" Height="20" Margin="10,6,0,0" VerticalAlignment="Top" Width="46" FontFamily="Georgia" Background="{x:Null}" Foreground="Black" FontSize="10" FontWeight="Bold"/>
<Label Content="Items remaining: " HorizontalAlignment="Left" Height="21" Margin="10,19,0,0" VerticalAlignment="Top" Width="110" FontFamily="Georgia" Background="{x:Null}" Foreground="Black" FontSize="10" FontWeight="Bold"/>
<TextBlock HorizontalAlignment="Left" Height="15" Margin="392,28,0,0" TextWrapping="Wrap" Text="88%" VerticalAlignment="Top" Width="28" FontSize="12" Opacity="0.6"/>
<TextBlock HorizontalAlignment="Left" Height="11" Margin="51,12,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="62" FontSize="9"/>
<TextBlock HorizontalAlignment="Left" Height="11" Margin="106,25,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="62" FontSize="9"/>
</Grid>
My question is about the events of these controls, does any of these controls have an event that triggers when the .showdialog() method executes, basically when the window appears?
Thanks in advance.
I'm starting to learn a little bit of WPF and Mahapps.metro, so I'm pretty new with those ones; here the question:
I have a button and two textboxes, the textboxes visibility is hidden when the forms loads, so when the user clicks the button, the textboxes visibility will be visible, but I want the textboxes to appear with that "slide" animation of the form load that Mahapps provides with the MetroWindow.
I tried using TransitioningContentControl but I couldn't make it happen. I would really appreciate your help, thanks.
My XAML:
<Controls:MetroWindow x:Class="practicas.nuevo"
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"
xmlns:local="clr-namespace:practicas"
mc:Ignorable="d"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviours="clr-namespace:MahApps.Metro.Behaviours;assembly=MahApps.Metro"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="Reporte Nuevo" Height="300" Width="574.444" Loaded="formload">
<Controls:MetroWindow.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Purple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Controls:MetroWindow.Resources>
<Grid>
<Controls:TransitioningContentControl x:Name="transitioning" Transition="Down"/>
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="238,89,0,0" VerticalAlignment="Top" Width="75" Click="button_Click"/>
<TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="95" Margin="345,51,0,0" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" VerticalAlignment="Top" Width="211" Controls:TextBoxHelper.Watermark="Hi Im a watermark" Background="#FF7400FF"/>
<TextBox x:Name="textBox2" HorizontalAlignment="Left" Height="95" Margin="0,51,0,0" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" VerticalAlignment="Top" Width="211" Controls:TextBoxHelper.Watermark="Hi im another watermark" Background="#FF7400FF"/>
</Grid>
</Controls:MetroWindow>
EDIT: This method gave me the solution, the only difference is that the control that I used was ContentControl instead of StackPanel, here is my xaml for anyone who wants to make something like this:
P.S: Marked as an answer, thanks man.
<Controls:TransitioningContentControl x:Name="transitioning" Transition="Left">
</Controls:TransitioningContentControl>
<Controls:TransitioningContentControl x:Name="transitioning2" Transition="Up">
</Controls:TransitioningContentControl>
<Controls:TransitioningContentControl x:Name="transitioning3" Transition="Up">
</Controls:TransitioningContentControl>
<ContentControl x:Name="panel" Margin="-10,0,0,0" Visibility="Hidden">
<Canvas x:Name="canvas">
<Label x:Name="label" Content="Reporte Recibido:" Canvas.Left="10" Canvas.Top="41" Width="112"/>
<Label x:Name="label2" Content="Acciones a tomar:" Canvas.Left="600" Canvas.Top="41" Background="{x:Null}" RenderTransformOrigin="0.497,0.551"/>
<Controls:ToggleSwitch x:Name="ToggleSwitch" Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" Canvas.Left="284" Canvas.Top="122" OnLabel="Confirmado" OffLabel="Por Confirmar" RenderTransformOrigin="0.5,0.5" Visibility="Hidden" Width="140" Checked="switched" Unchecked="unswitched" />
<Image x:Name="accion" Height="25" Width="33" Canvas.Left="671" Canvas.Top="218" Source="Imagenes/Add-New.png" MouseDown="accionagregar"/>
<RichTextBox x:Name="RichTextbox1" HorizontalAlignment="Left" Height="154" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" VerticalAlignment="Top" Width="284" Canvas.Left="438" Canvas.Top="64" TextChanged="textchanged" RenderTransformOrigin="0.815,0.541" Background="#FF7400FF" GotFocus="focus">
<xctk:RichTextBoxFormatBarManager.FormatBar >
<xctk:RichTextBoxFormatBar />
</xctk:RichTextBoxFormatBarManager.FormatBar>
<FlowDocument/>
</RichTextBox>
<RichTextBox x:Name="RichTextbox2" Background="#FF7400FF" Canvas.Top="64" GotFocus="reportefocus" Height="154" Width="274" Canvas.Left="5">
<xctk:RichTextBoxFormatBarManager.FormatBar >
<xctk:RichTextBoxFormatBar />
</xctk:RichTextBoxFormatBarManager.FormatBar>
<FlowDocument/>
</RichTextBox>
<Rectangle x:Name="reporteimagen" HorizontalAlignment="Left" Height="100" Margin="83,99,0,0" VerticalAlignment="Top" Width="100">
<Rectangle.Fill>
<VisualBrush Visual="{StaticResource appbar_book_open_text}"/>
</Rectangle.Fill>
</Rectangle>
<Rectangle x:Name="accionesimagen" HorizontalAlignment="Left" Height="100" Margin="536,99,0,0" VerticalAlignment="Top" Width="100" >
<Rectangle.Fill>
<VisualBrush Visual="{StaticResource appbar_book_list}"/>
</Rectangle.Fill>
</Rectangle>
<xctk:DateTimePicker x:Name="datetime" Width="162" Canvas.Left="504" Canvas.Top="218" Foreground="White" Format="Custom" FormatString="hh:mm tt" TimeFormat="Custom" TimeFormatString="hh:mm tt" CultureInfo="es-GT" ShowDropDownButton="False" Text="DefaultValue" IsReadOnly="True"/>
<Image x:Name="image7" Height="27" Canvas.Left="697" Canvas.Top="6" Width="33" Source="Imagenes/Repeat-All.png" RenderTransformOrigin="0.471,0.596" ToolTip="Reiniciar" MouseDown="reiniciar" Visibility="Hidden"/>
</Canvas>
</ContentControl>
<ContentControl x:Name="panel2" Visibility="Hidden">
<Canvas>
<Label x:Name="label5" Content="Reporte Creado Por:" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Canvas.Left="18" Canvas.Top="329" Background="{x:Null}" RenderTransformOrigin="0.497,0.551" Width="128"/>
<Label x:Name="label6" Content="Correlativo" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Canvas.Left="305" Canvas.Top="329" Background="{x:Null}" RenderTransformOrigin="0.497,0.551" Width="128"/>
<Label x:Name="label7" Content="Creado En:" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Canvas.Left="592" Canvas.Top="329" Background="{x:Null}" RenderTransformOrigin="0.497,0.551" Width="128"/>
<TextBox x:Name="textBox3" Height="23" HorizontalContentAlignment="Center" Canvas.Left="305" Canvas.Top="355" Width="128" IsReadOnly="True" Controls:TextBoxHelper.Watermark="Se genera al concluir."/>
<TextBox x:Name="textBox4" Height="23" HorizontalContentAlignment="Center" Canvas.Left="18" Canvas.Top="355" Width="128" IsReadOnly="True"/>
<TextBox x:Name="textBox5" Height="23" HorizontalContentAlignment="Center" Canvas.Left="592" Canvas.Top="355" Width="128" IsReadOnly="True"/>
<Image x:Name="image1" Height="44" Canvas.Left="504" Canvas.Top="337" Width="51" Source="Imagenes/Mail-Send.png" MouseDown="enviar" Visibility="Hidden"/>
<Image x:Name="image2" Height="44" Canvas.Left="225" Canvas.Top="337" Width="51" Source="Imagenes/User-Add.png"/>
<Image x:Name="image3" Height="44" Canvas.Left="169" Canvas.Top="337" Width="51" Source="Imagenes/Recycle-Bin.png" MouseDown="cancelar"/>
<Image x:Name="image5" Height="44" Canvas.Left="443" Canvas.Top="337" Width="51" Source="Imagenes/Lock.png"/>
<Image x:Name="image4" Height="44" Canvas.Left="443" Canvas.Top="337" Width="51" Source="Imagenes/Lock-Open.png"/>
</Canvas>
</ContentControl>
Example
You didn't place any content inside the transitioning content control. Try this:
<Grid>
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="238,89,0,0" VerticalAlignment="Top" Width="75" Click="button_Click"/>
<Controls:TransitioningContentControl x:Name="transitioning" Transition="Down">
<StackPanel>
<TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="95" Margin="345,51,0,0" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" VerticalAlignment="Top" Width="211" Controls:TextBoxHelper.Watermark="Hi Im a watermark" Background="#FF7400FF"/>
<TextBox x:Name="textBox2" HorizontalAlignment="Left" Height="95" Margin="0,51,0,0" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" VerticalAlignment="Top" Width="211" Controls:TextBoxHelper.Watermark="Hi im another watermark" Background="#FF7400FF"/>
</StackPanel>
</Controls:TransitioningContentControl>
</Grid>
Plus, reading the documentation, you'll see TransitioningContentControl performs the animation when the content changes. So you want to start with empty Transitioning Content Control, and then inside your Button click handler, set TransitioningContentControl Content dynamically to the two textboxes (need to be wrapped inside another control, like StackPanel, because transitioning control can only have a single child content.
Animations in WPF are quite tricky to pull of. I've made a fade animation a while back and it was quite a lot of work. Such a slide animation would require a lot of code and debugging to get it right. My recommendation is use a free slide animation library, and if you are feeling up to the task, you might be able to get a hold of some source code that you can use for inspiration if you want.
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.
Please I need assistance... My program which i am using c# and post relational database but i keep getting this error it says the xaml parse exception error was unhandled , please where am i going wrong the code is
<Window x:Class="zooSystemWorking.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="442" Width="884" Loaded="Window_Loaded" ResizeMode="NoResize">
<Grid Background="#F2C1D42D" Height="405">
<Image Height="139" HorizontalAlignment="Left" Margin="1,1,0,0" Source="/zooSystemWorking;component/Images/ZooLogo.jpg" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="104" />
<Border BorderBrush="#FF0A0A09" BorderThickness="1" Height="25" HorizontalAlignment="Left" Margin="6,145,0,0" Name="border1" VerticalAlignment="Top" Width="93" CornerRadius="10" Background="#95005202">
<Button Content="Add Animal" Height="23" Name="addAnimal" Click="addAnimal_Click" Width="87" Background="#95005202" Padding="0" BorderBrush="#95005202" Foreground="#F2C1D42D" />
</Border>
<Border BorderBrush="#FF101010" BorderThickness="1" Height="25" Name="border2" Width="93" Margin="6,185,764,195" CornerRadius="10" Background="#95005202">
<Button Content="View Animal" Height="23" Name="viewAnimal" Click="viewAnimal_Click" Width="86" Background="#95005202" Foreground="#F2C1D42D" />
</Border>
<Border BorderBrush="#FF0A0A09" BorderThickness="1" Height="25" Name="border3" Width="93" Margin="6,227,764,153" CornerRadius="10" Background="#95005202">
<Button Content="Update Animal" Height="23" Name="updateAnimal" Click="updateAnimal_Click" Width="84" Background="#95005202" Foreground="#F2C1D42D" />
</Border>
<Border BorderBrush="#FF0D0D0C" BorderThickness="1" Height="25" Name="border4" Width="93" Margin="6,268,764,112" CornerRadius="10" Background="#95005202">
<Button Content="Archive Animal" Height="23" Name="archiveAnimal" Click="archiveAnimal_Click" Width="84" Background="#95005202" BorderBrush="#95005202" Padding="0" Foreground="#F2C1D42D" />
</Border>
<ContentControl Height="326" HorizontalAlignment="Left" Margin="105,-1,0,0" Name="contentArea" VerticalAlignment="Top" Width="758" />
<Image Height="72" HorizontalAlignment="Left" Margin="1,333,0,0" Name="image2" Source="/zooSystemWorking;component/Images/grass.png" Stretch="Fill" VerticalAlignment="Top" Width="145" />
<Image Height="72" HorizontalAlignment="Left" Margin="142,333,0,0" Name="image3" Source="/zooSystemWorking;component/Images/grass.png" Stretch="Fill" VerticalAlignment="Top" Width="145" />
<Image Height="72" HorizontalAlignment="Left" Margin="286,333,0,0" Name="image4" Source="/zooSystemWorking;component/Images/grass.png" Stretch="Fill" VerticalAlignment="Top" Width="145" />
<Image Height="72" HorizontalAlignment="Left" Margin="429,333,0,0" Name="image5" Source="/zooSystemWorking;component/Images/grass.png" Stretch="Fill" VerticalAlignment="Top" Width="145" />
<Image Height="72" HorizontalAlignment="Left" Margin="572,333,0,0" Name="image6" Source="/zooSystemWorking;component/Images/grass.png" Stretch="Fill" VerticalAlignment="Top" Width="145" />
<Image Height="72" HorizontalAlignment="Left" Margin="717,333,0,0" Name="image7" Source="/zooSystemWorking;component/Images/grass.png" Stretch="Fill" VerticalAlignment="Top" Width="145" />
<Border Background="#95005202" BorderBrush="#FF0D0D0C" BorderThickness="1" CornerRadius="10" Height="25" Margin="6,305,763,75" Name="border5" Width="93">
<Button Background="#95005202" BorderBrush="#95005202" Click="reportGen_Click" Content="Report" Foreground="#F2C1D42D" Height="23" Name="reportGen" Padding="0" Width="84" />
</Border>
</Grid>
</Window>
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