I m new in WPF, i am developing a navigation application of WPF,
<NavigationWindow x:Class="KioskTraffic.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="768" Width="1024" Source="Home.xaml"
WindowState="Maximized" ResizeMode="NoResize" ShowsNavigationUI="False" WindowStyle="None" Cursor="Arrow" Closing="NavigationWindow_Closing"></NavigationWindow>
and i have some page which display in this navigarionwindow like
<Page x:Class="KioskTraffic.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Height="768" Width="1024"
Title="Page1">
How can i know which page is running currently under NavigationWindow.xaml.cs file?
I have a timer in this navigation window that want to check if current page is home.xaml then i don't want to start that timer.
You can get current running page in code behind using CurrentSource property of navigation window. As per your requirements, it's done using NavigationService.Navigate() method like below :
NavWindow.xaml :
NavWindow.xaml.cs :
ShopList.xaml :
ShopList.xaml.cs :
ProductList.xaml :
It's working fine for me. Hope this solve your problem. Please feel free to ask if it not solve.
UPDATE :
If you want to navigate page using class name instead of Uri then you can get current source like :