-
December 10th, 2016, 06:04 AM
#1
how to set Source of webbrowser to static string?
Hi,
im trying to set the source of a webbrowser to a static string, but when i run it i get an exception. Can anyone tell me why?
Code:
<Window x:Class="FlowDocTest.MainWindow"
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:clr="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:FlowDocTest"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<clr:String x:Key="gg">http://www.google.nl</clr:String>
</Window.Resources>
<Grid>
<!-- This throws an exception -->
<WebBrowser Source="{StaticResource gg}"/>
<!--This works:WebBrowser Source="http://www.google.nl" -->
</Grid>
</Window>
-
December 10th, 2016, 06:16 AM
#2
Re: how to set Source of webbrowser to static string?
Ok i found out what i was doing wrong:"Apparently the inner-exception was: Cannot convert string to URI.
So here is the corrected sample:
Code:
<Window x:Class="FlowDocTest.MainWindow"
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:sys="clr-namespace:System;assembly=System"
xmlns:local="clr-namespace:FlowDocTest"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.Resources>
<sys:Uri x:Key="strHTML">D:\Manual.html</sys:Uri>
</Grid.Resources>
<WebBrowser Source="{StaticResource strHTML}"/>
</Grid>
</Window>
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|