我有一个Web应用程序...我可以从网络驱动器中获取excel文件...使用
..所以我没有使用任何模仿。
我们是否有与WPF类似的内容?
修改: 我想在网络位置打开excel文件...当用户点击链接或按钮时。此外,我不想使用任何模仿...因为我们没有在a-href的情况下冒充。
答案 0 :(得分:2)
<Hyperlink NavigateUri="file:///networkShare/file">
Excel File
</Hyperlink>
答案 1 :(得分:0)
只需在Hyperlink
中加入TextBlock
,然后使用ValueConverter
参考网络值。
内部:View.xaml
<TextBlock x:Name="FileNamePresenter" Grid.Row="1" Text="{Binding FileName}" Margin="0,0,0.001,0" HorizontalAlignment="Stretch" d:LayoutOverrides="Height" Width="Auto" Grid.Column="1" >
<Hyperlink x:Name="FileLink" NavigateUri="{Binding FileName, ConverterParameter=FileName, Converter={StaticResource FileConverter}}"/>
</TextBlock>
valueConverter
namespace some.Helpers
{
public class JobFileConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string FileLocationPath = "";
try
{
if (value != null)
{
FileLocationPath= string.Format(@"file://SomesServer/f$/SomeFile/{0}.pdf",value);
}
}
catch { }
return FileLocationPath;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
最后在App.xaml(或资源字典)里面的胶水......
<Application x:Class="some.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:some.ViewModel"
xmlns:helper="clr-namespace:some.Helpers"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
StartupUri="JobList.xaml"
mc:Ignorable="d">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="someApp.xaml"/>
</ResourceDictionary.MergedDictionaries>
<!--Global View Model Locator-->
<vm:ViewModelLocator x:Key="Locator"
d:IsDataSource="True" />
<helper:JobStatusImageConverter x:Key="JobStatusConverter"/>
<helper:JobBindingImageConverter x:Key="JobBindingConverter"/>
<helper:JobFileConverter x:Key="FileConverter"/>
<Style x:Key="HeadingStyle" TargetType="{x:Type TextBlock}">
<Setter Property="TextWrapping" Value="NoWrap"/>
<Setter Property="TextTrimming" Value="None"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Color="#FFA52323" Direction="339" ShadowDepth="0"/>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
答案 2 :(得分:0)
使用此解决方案:How to make a simple hyperlink in XAML? 使按钮看起来像一个超链接。 (超链接无处不在。) 单击按钮时,请执行以下操作:
Process explorer = new Process();
explorer.StartInfo.FileName="explorer.exe";
explorer.StartInfo.Arguments = "/n, /e, /select," + path;
explorer.Start();