Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Silverlight HyperlinkButton到内部源_Silverlight_Hyperlink - Fatal编程技术网

Silverlight HyperlinkButton到内部源

Silverlight HyperlinkButton到内部源,silverlight,hyperlink,Silverlight,Hyperlink,我有一个SilverLight项目,在项目中我有一个PDF文档 如何创建对pdf文档的引用,以便通过单击Hyperlink按钮打开该文档?PDF文档上的构建操作应该是什么 提前感谢。您不应该将其包括在Silverlight项目中。而是将其作为标准web内容包含在关联的web项目中。例如,如果将其放置在web项目中名为Documents的文件夹中,则按钮的外观如下所示:- <HyperlinkButton Content="LaunchPDF" TargetName="_blank" Nav

我有一个SilverLight项目,在项目中我有一个PDF文档

如何创建对pdf文档的引用,以便通过单击Hyperlink按钮打开该文档?PDF文档上的构建操作应该是什么


提前感谢。

您不应该将其包括在Silverlight项目中。而是将其作为标准web内容包含在关联的web项目中。例如,如果将其放置在web项目中名为Documents的文件夹中,则按钮的外观如下所示:-

<HyperlinkButton Content="LaunchPDF" TargetName="_blank" NavigateUri="/Documents/MyDoc.pdf" />

我认为,使用HyperlinkButton的技巧不会奏效,因为您将导航到silverlight项目,而不是关联的web项目

您可以使用文件下载。我建议

祝你好运。

你可以使用ICommand:

ViewModel.cs:

        private static string _ApplicationUrl;
    public static string ApplicationUrl
    {
        get
        {
            if (_ApplicationUrl == null)
            {
                _ApplicationUrl = Application.Current.Host.Source.GetComponents(UriComponents.Scheme | UriComponents.Host | UriComponents.Port, UriFormat.UriEscaped);
                //_ApplicationUrl = HtmlPage.Document.DocumentUri.GetComponents(UriComponents.Scheme | UriComponents.Host | UriComponents.Port, UriFormat.UriEscaped);
            }
            return _ApplicationUrl;
        }
    }

    private RelayCommand<string> _WebUriCommand;
    public RelayCommand<string> WebUriCommand
    {
        get
        {
            if (_WebUriCommand == null)
            {
                _WebUriCommand = new RelayCommand<string>((p) => { HtmlPage.Window.Navigate(new Uri(ApplicationUrl + p), "_blank"); });
            }
            return _WebUriCommand;
        }
    }
View.xaml:

<HyperlinkButton Command="{Binding WebUriCommand}" CommandParameter="/Documents/MyDoc.pdf" Content="Download"/>

谢谢,我也考虑过了,但是我更愿意把这个文件放在我的Silverlight项目中。因为我希望能够独立于网站重新分发xap文件。@RvG:当它在xap中时,您将如何处理它?Silverlight无法直接使用PDF内容>其想法只是为了显示文档,我们使用PDF文件作为用户文档。正如我之前所写的,我们的想法是将文档放在XAP项目中,在重新分发应用程序时,您将始终拥有指向该文档的链接。谢谢,我没有意识到在Silverlight项目中引用简单文件会如此复杂。但公平就是公平,你不能指望一切都是直截了当的-我不知道这有什么帮助,一旦下载了,你会怎么处理?