I'm having trouble with the code below:
<Window x:Class="ChangePage.PageSwitcher"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ChangePage"
Title="ECE Showcase"
WindowState="Maximized">
<Window.Resources>
<local:PageSwitcher x:Name="pageTransitionControl" TransitionType="SlideAndFade"/>
</Window.Resources>
In the code behind file PageSwitcher.xaml.cs I have the following line:
pageTransitionControl.TransitionType = whatever;
However this results in the following error:
The name 'pageTransitionControl' does not exist in the current context
I've been searching around the Internet for a few hours now trying to find a reason for this but haven't been able to figure it out yet. Build Action is set to Page, all files are saved, I've tried rebuilding, PageSwitcher is in the ChangePage namespace and PageSwitcher has a constructor.
Is there something else I am doing wrong?
You cannot assign names to resources. Resources have keys.
<Window x:Class="ChangePage.PageSwitcher"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ChangePage"
Title="ECE Showcase"
WindowState="Maximized">
<Window.Resources>
<local:PageSwitcher x:Key="pageTransitionControl" TransitionType="SlideAndFade"/>
</Window.Resources>
Then in the xaml.cs:
var pageTransitionControl = (PageSwitcher)Resources["pageTransitionControl"];
pageTransitionControl.TransitionType = whatever;