Can someone please place me in the right direction.
I dont want to use hyperlink buttons. I want to use a normal silver light button from a usercontrol xaml.
At the moment I have no clue how to navigate to another page using a regular button. I know how to do it with Hyperlinks. I only want to use buttons at the moment.
Loading

Priya LingeRank #785 · 2.9K reputationPosted Aug 9, 2011, 8:55 PM EDT
We can navigate to another using silverligh Button by following way,
In MainPage.Xaml we have 1 frame as follow,
Button
I have another page is SecondPage.Xaml.
Mainpage.xaml.cs,On Button Click
private void button1_Click(object sender, RoutedEventArgs e)
{
Button theButton = sender as Button;
string url = theButton.Tag.ToString();
this.Frame.Navigate(new Uri(url, UriKind.Relative));
}
Please find attached file.
Hope this will help you.
Thanks.
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Aug 9, 2011, 8:57 PM EDT
You need to navigate another asp page or silverlight page?
David SmithRank #999 · 2K reputationPosted Aug 9, 2011, 9:51 PM EDT
I want to navigate using a normal button, not a hyper link button. Also can you guys point me to a good sight for learning silverlight
Priya LingeRank #785 · 2.9K reputationPosted Aug 9, 2011, 10:16 PM EDT
Given code is for silverlight. did you tried this for navigate to other page in silverlight.
i took normal button instead of hyperlink button in silverlight.
is this helpful or not?
Thanks.
David SmithRank #999 · 2K reputationPosted Aug 9, 2011, 10:21 PM EDT
Priya LingeRank #785 · 2.9K reputationPosted Aug 9, 2011, 10:35 PM EDT
David SmithRank #999 · 2K reputationPosted Aug 9, 2011, 10:35 PM EDT
Priya LingeRank #785 · 2.9K reputationPosted Aug 9, 2011, 10:47 PM EDT
private void button1_Click(object sender, RoutedEventArgs e)
{
Button theButton = sender as Button;
string url = theButton.Tag.ToString();
this.Frame.Navigate(new Uri(url, UriKind.Relative));
button1.Visibility = Visibility.Collapsed;
}
Thanks.
David SmithRank #999 · 2K reputationPosted Aug 9, 2011, 10:51 PM EDT
What does this particular line do, it this a valid fix. It seems like we are just hiding the button and thats its, I just made a example to go from page 1, to page 2, and to page 3, and all three buttons was still on the page.
Priya LingeRank #785 · 2.9K reputationPosted Aug 9, 2011, 11:01 PM EDT
As i said mainPage is a root page ,so the element which is on mainpage is always be there.
As we doing in asp Response.Redirect we are going to other page tht page url we can see.
in silverlight one default page i.e TestPage.aspx,url is same when we navigate to other page.
http://localhost:6680/drawlineTestPage.aspx
on click the SecondButton which is on MainPage,url changes to,
http://localhost:6680/drawlineTestPage.aspx#/Views/SecondPage.xaml
Thanks.
David SmithRank #999 · 2K reputationPosted Aug 9, 2011, 11:16 PM EDT
it will be something like this
http://localhost:6680/drawlineTestPage.aspx
on click the SecondButton which is on MainPage,url changes to,
http://localhost:6680/drawlineTestPage.aspx#/Views/SecondPage.xaml
on click the ThirdButton which is on MainPage,url changes to,
http://localhost:6680/drawlineTestPage.aspx#/Views/SecondPage.xaml/ThirdPage.xaml
and so far so on.
Can you email me [email protected]
Priya LingeRank #785 · 2.9K reputationPosted Aug 9, 2011, 11:41 PM EDT
Navigate to second Page then ,it will be,
http://localhost:6680/drawlineTestPage.aspx#/Views/SecondPage.xaml.
Navigate to Third Page then ,it will be,
http://localhost:6680/drawlineTestPage.aspx#/Views/ThirdPage.xaml
like this.
David SmithRank #999 · 2K reputationPosted Aug 10, 2011, 8:35 AM EDT
I have a few more questions.
Is there a value or a way i can iterate through all the buttons via the secondpage an do the Visibility.Collapsed;
for all the buttons I do not need.
private void button1_Click(object sender, RoutedEventArgs e)
{
Button theButton = sender as Button;
string url = theButton.Tag.ToString();
this.Frame.Navigate(new Uri(url, UriKind.Relative));
//I want to the foreach in this location
button1.Visibility = Visibility.Collapsed;
}
This is what i dont want to do below
this.SetConfigButton.Visibility = Visibility.Collapsed;
this.richTextBoxFilename.Visibility = Visibility.Collapsed;
this.labelConfigSettings.Visibility = Visibility.Collapsed;
this.labelFrames.Visibility = Visibility.Collapsed;
this.labelOperator.Visibility = Visibility.Collapsed;
this.labelPath.Visibility = Visibility.Collapsed;
this.labelTestType.Visibility = Visibility.Collapsed;
this.labelPartNumber.Visibility = Visibility.Collapsed;
this.labelPartNumber.Visibility = Visibility.Collapsed;
this.labelSerialNumber.Visibility = Visibility.Collapsed;
this.labelInformation.Visibility = Visibility.Collapsed;
David SmithRank #999 · 2K reputationPosted Aug 10, 2011, 2:50 PM EDT