105 lines
3.2 KiB
C#
105 lines
3.2 KiB
C#
//-----------------------------------------------------------------------
|
|
// <copyright file="NavigateButton.cs" company="BTU/IIT">
|
|
// Company copyright tag.
|
|
// </copyright>
|
|
// <author>stubbfel</author>
|
|
// <sience>08.07.2013</sience>
|
|
//----------------------------------------------------------------------
|
|
namespace CampusAppWP8.Utility.Lui.Button
|
|
{
|
|
using System;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
/// <summary>
|
|
/// This class create an Button which navigate to a certain page
|
|
/// </summary>
|
|
public class NavigateButton : System.Windows.Controls.Button
|
|
{
|
|
#region Members
|
|
|
|
/// <summary>
|
|
/// Register the UrlProperty
|
|
/// </summary>
|
|
public static readonly DependencyProperty NavigateProperty = DependencyProperty.Register("Url", typeof(object), typeof(NavigateButton), new PropertyMetadata(false));
|
|
|
|
/// <summary>
|
|
/// Register the QueryValueProperty
|
|
/// </summary>
|
|
public static readonly DependencyProperty QueryValueProperty = DependencyProperty.Register("QuerryStringValue", typeof(object), typeof(NavigateButton), new PropertyMetadata(false));
|
|
|
|
/// <summary>
|
|
/// Register the QueryNameProperty
|
|
/// </summary>
|
|
public static readonly DependencyProperty QueryNameProperty = DependencyProperty.Register("QuerryStringName", typeof(object), typeof(NavigateButton), new PropertyMetadata(false));
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="NavigateButton" /> class.
|
|
/// </summary>
|
|
public NavigateButton()
|
|
: base()
|
|
{
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Proberties
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Url
|
|
/// </summary>
|
|
public object Url
|
|
{
|
|
get { return (object)this.GetValue(NavigateProperty); }
|
|
set { this.SetValue(NavigateProperty, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the QueryStringName
|
|
/// </summary>
|
|
public object QuerryStringName
|
|
{
|
|
get { return (object)this.GetValue(QueryNameProperty); }
|
|
set { this.SetValue(QueryNameProperty, value); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets or sets the QueryStringValue
|
|
/// </summary>
|
|
public object QuerryStringValue
|
|
{
|
|
get { return (object)this.GetValue(QueryValueProperty); }
|
|
set { this.SetValue(QueryValueProperty, value); }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
/// <summary>
|
|
/// Overrides the OnClick-Method from button
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// now method navigate to a certain page
|
|
/// </remarks>
|
|
protected override void OnClick()
|
|
{
|
|
string urlString = this.Url as string;
|
|
|
|
if (this.QuerryStringName != null && this.QuerryStringValue != null)
|
|
{
|
|
urlString += "?" + this.QuerryStringName + "=" + this.QuerryStringValue;
|
|
}
|
|
|
|
Uri url = new Uri(urlString as string, UriKind.Relative);
|
|
Page page = App.RootFrame.Content as Page;
|
|
page.NavigationService.Navigate(url);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|