Hi guys I am new to app development and was wondeing how to transfer a textbox that holds a value to another page. My code is below:
Basket Button
private void Confirm_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(Confirmation) , Totaltxt_TextChanged = TotalValue);
}
The OnNav in which information needs being sent to
protected override void OnNavigatedTo(NavigationEventArgs e)
{
Basket Basket = e.Parameter as Basket;
if (Basket != null)
{
COsttxt.Text = string.Format("{0:C}", Basket.Totaltxt_TextChanged);
}
}
I have tried with just TotalValue which is the main value that needs to be sent but that seem to work I even set it in the textbox of the NavTo page:
<TextBox x:Name="COsttxt" HorizontalAlignment="Left" Height="58" Margin="229,258,0,0" TextWrapping="Wrap" Text="{Binding TotalValue}" VerticalAlignment="Top" Width="131" TextChanged="COsttxt_TextChanged"/>
So is there a way to just send the Totaltxt textbox from Basket.xaml and make the textbox value display in Confirmation.xaml?
You are passing a parameter to Confirmation page which I am sure is not of type Basket and hence you are getting null when you do as
conversion.
You should be simply passing/reading TotalValue this way:
private void Confirm_Click(object sender, RoutedEventArgs e)
{
Frame.Navigate(typeof(Confirmation) , TotalValue);
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var totalValue = e.Parameter as string; // or 'as' whatever is type of TotalValue
if (totalValue != null)
{
COsttxt.Text = string.Format("{0:C}", totalValue);
}
}
Edit: Pass the final textbox value as below and keep rest of the code same:
Frame.Navigate(typeof(Confirmation) , textboxName.Text);