Skip to content

Commit

Permalink
Add support for SL3 INavigate to PageFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Jul 25, 2009
1 parent 8594ae5 commit 43857b7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- Add XToolTipService
This is a tooltip service that supports creating tooltips that contain
binding expressions and share the DataContext of their associated element.
- PageFrame now implements INavigate from SL3, which allows the standard
HyperlinkButton to target PageFrame for its navigation.


0.3.1 Release (7/16/2009)
Expand Down
20 changes: 15 additions & 5 deletions src/Client/Core/UserInterface/Navigation/PageFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace SilverlightFX.UserInterface.Navigation {
[TemplatePart(Name = "ContentView", Type = typeof(ContentView))]
[TemplateVisualState(GroupName = "NavigationStates", Name = "Navigating")]
[TemplateVisualState(GroupName = "NavigationStates", Name = "Navigated")]
public class PageFrame : Control, INavigationTarget {
public class PageFrame : Control, INavigationTarget, INavigate {

/// <summary>
/// Represents the DefaultUri property.
Expand Down Expand Up @@ -102,6 +102,9 @@ public Uri DefaultUri {
return (Uri)GetValue(DefaultUriProperty);
}
set {
if ((value != null) && value.IsAbsoluteUri) {
throw new ArgumentException("DefaultUri must be set to a relative URI.", "value");
}
SetValue(DefaultUriProperty, value);
}
}
Expand Down Expand Up @@ -246,15 +249,16 @@ private ErrorPage GetErrorPage(Exception error) {
/// Naviates the frame to the specified URI.
/// </summary>
/// <param name="uri">The URI to navigate to.</param>
public void Navigate(Uri uri) {
public bool Navigate(Uri uri) {
if (uri == null) {
throw new ArgumentNullException("uri");
}
if (uri.IsAbsoluteUri) {
throw new ArgumentException("The uri to navigate to must not be absolute.");
return false;
}

SetValue(UriProperty, uri);
return true;
}

private bool NavigateInternal(NavigationState navigationState) {
Expand Down Expand Up @@ -517,8 +521,14 @@ event EventHandler<NavigatingEventArgs> INavigationTarget.Navigating {
}
}

void INavigationTarget.Navigate(Uri uri) {
Navigate(uri);
bool INavigationTarget.Navigate(Uri uri) {
return Navigate(uri);
}
#endregion

#region INavigate Members
bool INavigate.Navigate(Uri uri) {
return Navigate(uri);
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Uri Uri {
/// Navigates the control to the specified URI.
/// </summary>
/// <param name="uri">The URI to navigate to.</param>
void Navigate(Uri uri);
/// <returns>True if the control could handle the navigation; false otherwise.</returns>
bool Navigate(Uri uri);
}
}

0 comments on commit 43857b7

Please sign in to comment.