2011-11-25 49 views
0

我是silverlight的新手。请帮我找到设置页面标题。 enter image description here页面标题在Silverlight 4中

请参阅我不想/浏览器标题中的/Pages/Page1.xaml。

private void hlHome_Click(object sender, RoutedEventArgs e) 
    { 
     //HtmlDocument document = HtmlPage.Document; 
     //document.SetProperty("title", "Sample Title"); 
     this.frameContainer.Navigate(new Uri("/Pages/Home.xaml", UriKind.Relative)); 
    } 

    private void frameContainer_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e) 
    { 
     e.Handled = true; 
     frameContainer.Navigate(new Uri("/Pages/ErrorPage.xaml", UriKind.Relative)); 
    }  
+0

在地址栏中完整URL的外观如何? – AnthonyWJones

+0

@AnthonyWjones:http:// localhost:4816/SilverlightApplication1TestPage.aspx#/ Pages/Page1.xaml –

回答

1

这听起来对我来说,你没有指定在你的Page1.xamlTitle财产。

<navigation:Page x:Class="NavApp.Views.Page1" 
     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" 
     xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
     d:DesignWidth="640" d:DesignHeight="480" Background="Blue" 
     Title="Your title here" 
     > 

Altenatively如果你需要动态分配的标题,你可以在过程中的代码隐藏OnNavigatedTo做的代码。

2

试试这个:

HtmlDocument document = HtmlPage.Document; 
document.SetProperty("Title", "Sample Title"); 

参考Here

+0

这段代码应该写在哪里?我试过但没有工作。 –

+0

感谢您的回复。此代码是否应该写入xaml文件或.aspx文件中? –

+0

@Mohan这需要在您的Silverlight导航代码中。当你让新视图可见时调用它。 – ChrisF

-1

HtmlPage.Document.SetProperty(“Title”,“Sample”);

工作对我