Skip to main content
Home Forums Silverlight Design Designing with Silverlight I'm trying to put hyperlink button it gives me an error
14 replies. Latest Post by Min-Hong Tang - MSFT on November 3, 2009.
(0)
banderas...
Member
9 points
56 Posts
10-29-2009 1:40 AM |
Hi everyone my problem is I have hyperlink button in my let say page1.xaml to go to page.xaml
<HyperlinkButton Margin="219,171,0,0" VerticalAlignment="Top" TargetName="_blank" Height="54" HorizontalAlignment="Left" Width="69" Grid.Column="1" NavigateUri="/Page2.xaml"> it gives me an error
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /Page1.xaml can anyone help me please
mahedi
8 points
4 Posts
10-29-2009 2:03 AM |
You can check the following as in order..
1. Whether Page2.xaml exists
2. Where have you placed Page2.xaml?
3. If you have placed Page2.xaml in a folder named ABC, then write NavigateUri="/ABC/Page2.xaml"
watabou
418 points
75 Posts
10-29-2009 2:08 AM |
Silverlight is a RIA and doesn't navigate from xaml to xaml as all youre doing is on the same page : Your website only have a package with the .xap extension and xaml are not pages but UserControls displayed on the same web page where you put your Silverlight Control.
To go from a UserControl to another, youcan play on the opacity of your controls.
Add your page2 UserControl on your page1.xaml ( at the bottom of your Grid/Canvas LAyoutRoot to be sure it will be display on top) and put its opacity to 0
erase your HyperLinkButton and put a simple Button instead, in which click event you will change the opacity of your Page2 UserControl to 1.
There's a lot of different way to do it, but here is the simplest :
Page1.xaml
<UserControl x:Class="SilverlightForum.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" xmlns:page="clr-namespace:SilverlightForum" mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"> <Grid x:Name="LayoutRoot"> <Button Name="MyButton" Height="80" Width="200" Content="Go to Page2" Click="Button_Click" />
<page:SilverlightControl1 Opacity="0" Name="Page2"/> </Grid></UserControl>
Page1.xaml.cs
namespace SilverlightForum{ public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { MyButton.Opacity = 0; Page2.Opacity = 1; } }}
PAge2.xaml
<UserControl x:Class="SilverlightForum.SilverlightControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300"> <Grid x:Name="LayoutRoot" Background="Black"> </Grid></UserControl>
amyo
Contributor
3660 points
495 Posts
10-29-2009 2:11 AM |
You can not access Page1.xaml in this way.
You can use the Navigation Framework of SL 3 instead.
10-29-2009 2:28 AM |
I see what you are saying but the problem I have many videos to put
10-29-2009 2:46 AM |
if you have a lot of UserControl, then you can load theim dynamically on your Page1 ( see : http://forums.silverlight.net/forums/t/137688.aspx ).
10-29-2009 3:13 AM |
thank you for your help honestyl I'm not an expert here is my page
http://theindieshow.vircas.com/ now as you see when you click any of the picture the video comes out I already creat xaml the page you see
then I have another xaml where it only has the media skin player with the .wmv related to the singer how to load it dynamically the videos thank you
10-29-2009 3:31 AM |
what about if I creat my media in .htm not xaml can I link them with
10-29-2009 3:44 AM |
The only difference with xaml is that you wont pass some request by Post or Get, but directly change some properties of your code
Just give some properties to your xaml with the media player as : source / title etc .. When you click the button and load your skin player, just load your source with this property.
If we take back the first post i gave you, let's assume you have one button for each videos ( let say button_1 / button_2 .. ), then in the click event you will just have to do something like :
private void Button_Click(object sender, RoutedEventArgs e) { Button myButton = sender as Button
switch ( myButton.Name)
{
case "Button_2" :
Page2.DynamicVideo("My video 2","/Videos/2.wmv");
break;
etc..
}
And in your page2 which contain the media player, just add a function :
DynamicVideo(string Title, string sourcePath)
//Your code for giving the source to the video player and a title to display on the page
If you don't want to do your media player with Silverlight, you can also link the both with Hyperlink of course.
10-29-2009 3:46 AM |
You can use ChildWindow like below:
<HyperlinkButton Content="Video1" Click="HyperlinkButton_Click"></HyperlinkButton>
Code:
private void HyperlinkButton_Click(object sender, RoutedEventArgs e) { ChildWindowVideo cwv = new ChildWindowVideo(); cwv.Show(); }
You child window (SL 3):
<controls:ChildWindow x:Class="SilverlightApplication1.Views.ChildWindowVideo" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" Width="400" Height="300" Title="ChildWindowVideo"> <Grid x:Name="LayoutRoot" Margin="2"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <!--Your video page xaml here--> <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" /> <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" /> </Grid> </controls:ChildWindow>
10-29-2009 4:08 AM |
now do I add video xaml code or just le say my player is in play1.xaml
which one thank you
10-29-2009 4:21 AM |
it gives me two errors one controls is not defined. childwindow is not supported in silverlight project
10-29-2009 5:23 AM |
ChildWindow is a Silverlight 3.0 feature.
In Visual Studio SL project >> ADD>> New Item>>Select Silverlight Child Window
Check here :http://www.wintellect.com/CS/blogs/jprosise/archive/2009/04/29/silverlight-3-s-new-child-windows.aspx
and also,
http://www.uxpassion.com/2009/08/silverlight-3-tutorial-how-to-use-childwindow-webcast/
10-29-2009 2:26 PM |
I apreaciate thank you now one question I'm using net 4.0 it gives me a warning couldnt read unable to find an assembly microsoft.build.task. v4.0 and hen I click on the button it pops up very tiny the child window
Min-Hong...
3584 points
411 Posts
11-03-2009 1:51 AM |
Hi,
You have to decorate the child window yourself. In your case you can put your Media player in the child window. When users click a button or a img on the main page. The child window with a Media player pops up and plays the right video.
Here is a link about how to use child window(it's a webcast):
Best Regards