Can't able to Run the basic Silverlight application - silverlight

When I try to run a simple, basic Silverlight application, I got the following error:
Can't find the TestPage.html, Make
sure the path or internet address is
correct.
Here is my XAML code:
<UserControl x:Class="HelloWorld.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:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot" Background="White">
<TextBlock Text="Hello, World!" />
</Grid>
</UserControl>
What could be the reason for this? Any help would be greatly appreciated.
Thanks.

This sounds like an issue with your project setup. Make sure your ASP.NET project is correctly set with your Silverlight project as a contained Silverlight app. Also you will want to check that in the Project Properties the Startup Item is set to an existing page. It may not be TestPage.html.

Related

Error XLS0502 The 'WindowsFormsHost' type does not support direct content

I'm trying to use a winform control in WPF(I've not found good alternative).
The control is the be.hexbox from sourceforge: https://sourceforge.net/projects/hexbox/files/hexbox/
So I Start a new solution VB.net WPF and add WindowsFormsIntegration.dll reference.
I also add reference to the control dll.
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wf="clr-namespace:Be.Windows.Forms;assembly=Be.Windows.Forms.HexBox"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp2"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<WindowsFormsHost Name="TEST1">
<wf:HexBox x:Name="HX" />
</WindowsFormsHost>
</Grid>
</Window>
but I get this error:
Error XLS0502 The 'WindowsFormsHost' type does not support direct content.
Any advice?
Indeed, you can't set a direct Content in a WindowsFormsHost element, you need to set the Child property instead.
Try this:
<WindowsFormsHost Name="TEST1">
<WindowsFormsHost.Child>
<wf:HexBox x:Name="HX" />
</WindowsFormsHost.Child>
</WindowsFormsHost>
The project must have a reference to both:
WindowsFormsIntegration
System.Window.Forms
In my experience you do not need to specify <WindowsFormsHost.Child> in XAML. This may be dependent on the version. I am currently using .NET Framework 4.8.

Application Commands is not supported in WPF

using WPF (beginner) :-)
i keep getting the error
"ApplicationCommans is not supported in a Windows Presentation Foundation (WPF) project"
i just begin my project ..
Solution Platform : AnyCPU
<Window x:Class="Wpf_CreatingARichTextEditor.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:Wpf_CreatingARichTextEditor"
mc:Ignorable="d"
Title="MainWindow" Height="300" Width="400">
<Window.CommandBindings>
<CommandBinding Command="ApplicationCommans.Open"
Executed="CommandBinding_Executed" />
</Window.CommandBindings>
<Grid>
</Grid>
</Window>
thanks
It's not ApplicationCommans..it's ApplicationCommands.Open. Just change the name of the command it should fix the issue.
Hope this helps.
For me, I got this issue when copying from MSDN and pasting into the XAML. There was an invisible zero-width joiner character between Application and Commands that I had to delete (presumably to help with word-wrapping)

xaml image not displayed during runtime but displaying during design (VB, wpf) - why?

I'm trying to understand WPF and have created a WPF test project. I've put a monkey01.jpg image in every folder starting from the project's root, moving up in hierarchy, to the debug folder. On the MainWindow I've created an Image and defined the source property to point to the monkey01.jpg and it displays correctly in design view. But when I run it, the image doesn't appear.
If I add the image file to the project as a resource, it will be displayed during runtime which is expected. (But this is not what I'm testing here)
If in the xaml file I write the absolute path as in Source="C:\Users\User\Desktop\visual_studio_projects\WpfApplication1\monkey01.jpg it will be displayed too.
But if I use a relative path (like in the example below), the image won't be displayed. It's as if upon execution, the program doesn't run inside the project folder and its subfolders; Instead it runs in some other location that has no access the image. Why this behaviour? What am I missing?
This is the MainWindow.xaml code:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Image x:Name="Thumbnailtest" Source="monkey01.jpg" />
</Grid>
</Window>
Thank you!
You need to set Copy to Output Directory in the Properties Window for the image to "Copy if newer".
Works fine here when I've set the image to Resource and don't copy, note I changed your monkey image to .png and I created a folder for it(Data/Images).
<Window x:Class="MasoneryLibrary.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MasoneryLibrary;assembly=MasoneryLibrary"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid>
<Image Source="Data/Images/monkey01.png" HorizontalAlignment="left" VerticalAlignment="Top" Width="290" Height="456" Margin="285,0,-58,-136" Stretch="None" StretchDirection="DownOnly"/>
</Grid>
</Grid>
Hmmmm.. is this a library? You should use URI packs to be safe.
With URI pack:
<Image Source="pack://application:,,,/MasoneryLibrary;component/Data/Images/monkey01.png" HorizontalAlignment="left" VerticalAlignment="Top" Width="290" Height="456" Margin="285,0,-58,-136" Stretch="None" StretchDirection="DownOnly"/>
Hope it helps!
Cheers,
Stian

WPF: Use PropertyGrid from WPF Extended

I'm new in WPF (.NET 4.0, VS2010) and try to include a property grid. My XAML Markup looks like the following:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfToolkit="clr-namespace:Xceed.Wpf.Toolkit.PropertyGrid;assembly=WPFToolkit.Extended"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WpfToolkit:PropertyGrid Name="Grid" />
</Grid>
</Window>
Now I get the error that the assembly 'WPFToolkit.Extended' was not found. I have included the reference to the dll Xceed.Wpf.Toolkit.dll in my application.
Why does it not work? Have I to include more references or what can be the mistake?
Thanks for any Response.
I could solve the problem. My fault was that I had not unblocked the zip file containing the dll. After this I have to change the source for the namespace in the Markup to an uri. Below the final markup:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfToolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
Title="MainWindow" Height="350" Width="525">
<Grid>
<WpfToolkit:PropertyGrid Name="Grid" />
</Grid>
</Window>
Check your project properties. Under application, what is selected under target framework? By default with a new project, '.Net Framework 4 Client Profile' is selected. If the extended library uses parts of .net that beyond the client profile, you will need to select '.Net Framekwork 4' instead to use the extended functionality.

Visual Studio 2010 - Dictionary Not found but it exists

Well, I´m developing a wpf application and I got a strange error on design time. This is the code of a wpf form:
<Window x:Class="ViewLayer.Frm_EnrollWaitingList"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Frm_EnrollWaitingList" WindowStartupLocation="CenterScreen" BorderBrush="{x:Null}" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="390" Width="410"
WindowStyle="None"
AllowsTransparency="True"
ResizeMode="NoResize">
<Window.Resources>
<ResourceDictionary Source="Dictionary/WaitingListDictorionary.xaml"/>
</Window.Resources>
<Grid>
<Rectangle Margin="0,0,0,0" Name="rectangle1" Stroke="{x:Null}" Fill="#FF8C90AD" Opacity="0.95" />
<Button Style="{DynamicResource CommonButton}" Content="Salir" Height="80" HorizontalAlignment="Left" Margin="166,234,0,0" Name="btn_close" VerticalAlignment="Top" Width="180" />
</Grid>
</Window>
The problem starts here:
<Window.Resources>
<ResourceDictionary Source="Dictionary/WaitingListDictorionary.xaml"/>
</Window.Resources>
The ResourceDictionary exits and in execution time it works perfectly. But at design time sometime when a want to modify the form in visual studio designer i get the following error:
FileNotFoundException An error occurred while finding the resource dictionary "Dictionary/WaitingListDictorionary.xaml".
Unable to find the specified file.
at Microsoft.Windows.Design.Platform.ViewProducerBase.Microsoft.Expression.DesignModel.DocumentModel.IDocumentRootResolver.GetDocumentRoot(String path)
at Microsoft.Expression.Platform.WPF.InstanceBuilders.ResourceDictionaryInstanceBuilder.ProvideResourceDictionary(IInstanceBuilderContext context, DocumentCompositeNode resourceDictionaryReferenceNode, IDocumentRoot& relatedRoot)
And I can not edit the form with the designer.
Any idea? I repeat on execution time I have no problems.
The Source property is relative, and you window appears to be in the ViewLayer directory, so the Dictionary folder must also be in the ViewLayer directory if you use
Source="Dictionary/WaitingListDictorionary.xaml".
If the Dicionary folder is at the root level, try
Source="/Dictionary/WaitingListDictorionary.xaml".
You can also use a pack:// URL.
I could figure it out!
There was an error on the ResourceDictionary I was trying to use. I fixed it, and voila! Everything works like a charm.

Resources