I’m trying to use the coding4fun toolkit for windows phone 7.
InputPrompt input = new InputPrompt();
whoAreYou.Completed += input_Completed;
input.Title = "Who are you?";
input.Message = "Enter your name";
input.Show();
void input_Completed(object sender, PopUpEventArgs<object, PopUpResult> e)
{
//add some code here
InputPrompt input = sender as InputPrompt;
MessageBox.Show(input.Value);
}
This throws the exception below:
Reference is not a valid visual DependencyObject
I want to ask the user for his/her name.
I’m following this tutorial and have added the necessary assembly references.
How can I get the coding4fun toolkit to work?
Edit:
If I do this in xaml like
<c4f:InputPrompt x:Name="input" Completed="input_Completed_1" />
Then this works, but I need it to work with code.
I’ve reproduced your bug when I’ve added the code presented to the Main Page constructor. It seems like an InputPrompt isn’t added to the visual tree (just a theory) and that’s why can’t be shown.
When I’ve changed the code to show InputPrompt upon Loaded event, everything worked fine. Basically, you have to wait until the page is loaded or put the control in your XAML file.