locked
Can I change the NavigateUri of a hyperlink button using a visual state? RRS feed

  • Question

  • Can I change the NavigateUri of a hyperlink button using a visual state? 

    I tried by writing what is below but it had no effect. Am I going about this the wrong way or is there no way to do this? I could find anything online so I though I would ask.

     

    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(HyperlinkButton.NavigateUri)" Storyboard.TargetName="hyperlinkButton">

    <DiscreteObjectKeyFrame KeyTime="0" Value="/testdeletelate;component/Page2.xam"/>

    </ObjectAnimationUsingKeyFrames>

     

    Thanks you in advance

    Breht

    Wednesday, October 19, 2011 11:15 PM

Answers

  • I don't think you can.  If you change the NavigateUri during State recording, it changes it for all states.

    You could do it in code-behind based on the current state you are in...

                           string a = VisualStateGroup.CurrentState.Name.ToString();
    			if (a == "state1")
    			{
    				this.myHyperlinkBtn.NavigateUri = new Uri("http://microsoft.com");
    			}
    			else if (a == "state2")
    			{
    				this.myHyperlinkBtn.NavigateUri = new Uri("http://expression.microsoft.com");
    			}
    

    ~Christine

    • Marked as answer by breht Thursday, October 20, 2011 5:54 PM
    Thursday, October 20, 2011 1:17 AM

All replies

  • I don't think you can.  If you change the NavigateUri during State recording, it changes it for all states.

    You could do it in code-behind based on the current state you are in...

                           string a = VisualStateGroup.CurrentState.Name.ToString();
    			if (a == "state1")
    			{
    				this.myHyperlinkBtn.NavigateUri = new Uri("http://microsoft.com");
    			}
    			else if (a == "state2")
    			{
    				this.myHyperlinkBtn.NavigateUri = new Uri("http://expression.microsoft.com");
    			}
    

    ~Christine

    • Marked as answer by breht Thursday, October 20, 2011 5:54 PM
    Thursday, October 20, 2011 1:17 AM
  • thank you so much that is easier to deal with anyways
    Thursday, October 20, 2011 5:55 PM