Thanks to this question (click me!), I have the Source
property of my WebBrowser
binding correctly to my ViewModel.
Now I'd like to achieve two more goals:
- Get the
IsEnabled
property of my Back and Forward buttons to correctly bind to theCanGoBack
andCanGoForward
properties of theWebBrowser
. - Figure out how to call the
GoForward()
andGoBack()
methods without resorting to the code-behind and without the ViewModel having to know about theWebBrowser
.
I have the following (non-working) XAML markup at the moment:
<WebBrowser
x:Name="_instructionsWebBrowser"
x:FieldModifier="private"
clwm:WebBrowserUtility.AttachedSource="{Binding InstructionsSource}" />
<Button
Style="{StaticResource Button_Style}"
Grid.Column="2"
IsEnabled="{Binding ElementName=_instructionsWebBrowser, Path=CanGoBack}"
Command="{Binding GoBackCommand}"
Content="< Back" />
<Button
Style="{StaticResource Button_Style}"
Grid.Column="4"
IsEnabled="{Binding ElementName=_instructionsWebBrowser, Path=CanGoForward}"
Command="{Binding GoForwardCommand}"
Content="Forward >" />
I'm pretty sure the problem is that CanGoBack
and CanGoForward
are not dependency properties (and don't implement INotifyChanged
), but I'm not quite sure how to get around that.
Questions:
Is there any way to hook up attached properties (as I did with
Source
) or something similar to get theCanGoBack
andCanGoForward
bindings to work?How do write the
GoBackCommand
andGoForwardCommand
so they are independent of the code-behind and ViewModel and can be declared in markup?