I am new to WPF, C# and xaml. I'd describe my knowledge as poor, but growing.
I have a very simple application. What I am trying to accomplish is the following:
I have a textbox, and I'm asking the user of the application to enter an email address. I'd like to store that variable somewhere, where I can write it to the screen later. So: 1. Get the email address (User hits a 'Next' button) 2. "Thanks an email will be set to " "when the utility is finished."
I'm using Blend with SketchFlow. I created a singleton class that allows me to store the variable.
namespace Mysillyapplication
{
public class ApplicationParameters
{
private static ApplicationParameters _instance;
private string _emailAddress;
public static ApplicationParameters Instance
{
get
{
if (_instance == null)
{
_instance = new ApplicationParameters();
}
return _instance;
}
}
public string EmailAddress
{
get { return _emailAddress; }
set
{
_emailAddress = value;
}
}
}
The code for the page that gets the email address:
namespace Mysillyapplication
{
/// <summary>
/// Interaction logic for BasicParameters.xaml
/// </summary>
public partial class BasicParameters : UserControl
{
public BasicParameters()
{
this.InitializeComponent();
}
public string EmailAddress
{
get
{
return ApplicationParameters.Instance.EmailAddress;
}
set
{
ApplicationParameters.Instance.EmailAddress = value;
}
}
}
}
In my xaml I have the following lines:
<TextBox x:Name="email" HorizontalAlignment="Left" Height="23" Margin="32,65,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="291"/>
AND
<i:EventTrigger EventName="Click">
<ei:ChangePropertyAction TargetName="MySillyapplication_BasicParameters_Name" PropertyName="EmailAddress" Value="{Binding Text, ElementName=email}" />
<pi:NavigateToScreenAction TargetScreen="DBSyncScreens.BeginSync"/>
</i:EventTrigger>
AND Finally, I want to display it out on another page: In that page's CS I have the following lines:
public string EmailAddress
{
get
{
return ApplicationParameters.Instance.EmailAddress;
}
set
{
ApplicationParameters.Instance.EmailAddress = value;
}
}
And in the XAML:
<TextBlock HorizontalAlignment="Left" Height="25" Margin="10,35,0,0" Style="{DynamicResource BasicTextBlock-Sketch}"
VerticalAlignment="Top" Width="605" >
<Run Text="A log of the sync will be sent to "/>
<Run Text="{Binding EmailAddress, Mode=TwoWay}"/>
<Run Text=". Click Next to begin the sync process."/>
</TextBlock>
is wrong and doesn't work.
I could be doing this the wrong way. Anyone have any ideas on how to easily make that user variable email address easy to handle. I feel like what I'm trying to accomplish is very easy, yet I'm having so much difficulty with it.
get a variable, store it, access it on other pages.