Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there an MVVM-friendly way to use the WebBrowser control in WPF?
    primarykey
    data
    text
    <p>Thanks to <a href="https://stackoverflow.com/questions/263551">this question (click me!)</a>, I have the <code>Source</code> property of my <code>WebBrowser</code> binding correctly to my ViewModel.</p> <p>Now I'd like to achieve two more goals:</p> <ol> <li>Get the <code>IsEnabled</code> property of my Back and Forward buttons to correctly bind to the <code>CanGoBack</code> and <code>CanGoForward</code> properties of the <code>WebBrowser</code>.</li> <li>Figure out how to call the <code>GoForward()</code> and <code>GoBack()</code> methods without resorting to the code-behind and without the ViewModel having to know about the <code>WebBrowser</code>.</li> </ol> <p>I have the following (non-working) XAML markup at the moment:</p> <pre><code>&lt;WebBrowser x:Name="_instructionsWebBrowser" x:FieldModifier="private" clwm:WebBrowserUtility.AttachedSource="{Binding InstructionsSource}" /&gt; &lt;Button Style="{StaticResource Button_Style}" Grid.Column="2" IsEnabled="{Binding ElementName=_instructionsWebBrowser, Path=CanGoBack}" Command="{Binding GoBackCommand}" Content="&amp;lt; Back" /&gt; &lt;Button Style="{StaticResource Button_Style}" Grid.Column="4" IsEnabled="{Binding ElementName=_instructionsWebBrowser, Path=CanGoForward}" Command="{Binding GoForwardCommand}" Content="Forward &amp;gt;" /&gt; </code></pre> <p>I'm pretty sure the problem is that <code>CanGoBack</code> and <code>CanGoForward</code> are not dependency properties (and don't implement <code>INotifyChanged</code>), but I'm not quite sure how to get around that.</p> <p><strong>Questions:</strong></p> <ol> <li><p>Is there any way to hook up attached properties (as I did with <code>Source</code>) or something similar to get the <code>CanGoBack</code> and <code>CanGoForward</code> bindings to work?</p></li> <li><p>How do write the <code>GoBackCommand</code> and <code>GoForwardCommand</code> so they are independent of the code-behind and ViewModel and can be declared in markup?</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload