hi!!!
i have used RoutedEventArgs please follow the steps.
Step1:App.xaml
<Application x:Class="CRC.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Start" >
</Application>
Step2:App.cs
public partial class App : Application
{
private void Application_Start(Object sender, System.Windows.StartupEventArgs e)
{
MainWindow mainWindow = new MainWindow();
mainWindow.ShowDialog();
}
}
}
Step3:MainWindow.Xaml
<Window x:Class="CRC.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CRC"
Title="CRC Application" Width="1280" Height="960"
MinHeight="800" MinWidth="600" HorizontalAlignment="center" mc:Ignorable="d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="960"
d:DesignWidth="1280" WindowState="Maximized" WindowStyle="None" Topmost="False" MouseDown="MainWindow_MouseDown" AllowsTransparency="False" Visibility="Collapsed">
<Grid x:Name="grdMain" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Viewbox Stretch="Fill">
<Frame x:Name="_mainFrame" NavigationUIVisibility="Hidden" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Margin="0" ClipToBounds="False"/>
</Viewbox>
</Grid>
</Window>
Step4:Wpf Page
namespace Application
{
/// <summary>
/// Interaction logic for wpfPage.xaml
/// </summary>
public partial class wpf : Page
{
public static readonly RoutedEvent TimeOutEvent = EventManager.RegisterRoutedEvent("TimeOut", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(WpfPage));
//******************************************
public AddressPage()
{
InitializeComponent();
}
public event RoutedEventHandler TimeOut
{
add { AddHandler(TimeOutEvent, value); }
remove { RemoveHandler(TimeOutEvent, value); }
}
void RaiseTimeOutEvent()
{
RoutedEventArgs newEventArgs = new RoutedEventArgs(WpfPage.TimeOutEvent);
RaiseEvent(newEventArgs);
}
private void btnEnter_Click(object sender, RoutedEventArgs e)
{
RaiseTimeOutEvent();
}
}
Step5:Mainwindow.cs
public partial class MainWindow : Window
{
public MainWindow()
{
InitializePage();
}
private void InitializePage()
{
WpfPage wpfpage=new WpfPage();
this.AddHandler(WpfPage.TimeOutEvent, new RoutedEventHandler(HandleWpfPageTimeOut));
}
private void HandlePageTimeOut(object sender, RoutedEventArgs args)
{
_mainframe.navigate(wpfpage);
}
}
BY
Rajesh
MY Mail Id:rajesh4132@gmail.com
India
If it helps/directs you towards the solution,Mark This Response as Answer link
--
Rajesh
Vuyiswamb, if this helps please login to Mark As Answer. | Alert Moderator