views:

29

answers:

1

I have this for a hyperlinkbutton:

<HyperlinkButton x:Name="Home" 
  NavigateUri="/Home" 
  TargetName="ContentFrame" 
  Content="Home" 
  Style="{StaticResource HyperlinkButtonStyle1}">

Trying to accomplish the same using <Button>, any ideas?

A: 

Its pretty simple. All you need to do is change the template to make it look the way you want.

Here's a blog post which goes into the details for changing the template for a Button. All you need to do is change the template to something like:

<ControlTemplate TargetType="Button">
  <TextBlock Foreground="Blue">
      <ContentPresenter/>
  </TextBlock>
</ControlTemplate>

Of course, you might be able to sneak out the template for a HyperlinkButton using Expression (it might also be lurking somewhere on MSDN) and reuse it...


With a button, I'd do the folowing (using codebehind blech):

<button Content="Navigate to my page!" Click="Button_Click" />

and in the codebehind:

    void Button_Click(object sender, RoutedEventArgs e)
    {
        // Instantiate the page to navigate to
        var page = new MyPage();

        // Navigate to the page, using the NavigationService
        // this assumes that the event handler is inside of a
        // NavigationWindow
        this.NavigationService.Navigate(page);
    }
Will
I am looking for the navigation uses. To put a panel in a target frame. I am sure it is pretty simple, just not sure how to do it.
@user Well, its not exactly that simple. Are you using navigation controls (such as NavigationWindow) or are you muscling it via codebehind/ViewModel?
Will
@ Will,I am using navigation controls
@user Answer updated.
Will