Reputation:
This is a Water Hackathon, 2014 Project. I am a newbie in windows phone. I was developing an app for a project. part of the app is that user will write his number and some text and the number and text will be emailed to a particular person. I used drag n drop UI and wrote the code of email send in Visual C#. Here is the error:
Failed to assign to property 'System.Windows.UIElement.AllowDrop'.[Line: 53 Position: 76]
at
System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at
PhoneApp2.MainPage.InitializeComponent()
at PhoneApp2.MainPage..ctor()
part of the C# code:
private void emailSend(object sender, RoutedEventArgs e)
{
// Create a new instance of the class EmailComposeTask with which you can send email
var emailcomposer = new EmailComposeTask
{
// I enter the recipients to send the email using the To property of the class
EmailComposeTask
To = string.Concat("mailto:","[email protected]"),
// Set the title of the property by Subject
Subject = "number",
// Enhanced the value of the Body property EmailComposeTask class, this is the
content that will display the recipient
Body = bigText.Text,
};
// Start the email application on your device to send the Email
emailcomposer.Show();
}
part of the XAML file:
<TextBlock Text="Wheres the problem" Style="{StaticResource PhoneTextNormalStyle}"
FontSize="36" FontFamily="Andalus"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="10,0,14,0"
RenderTransformOrigin="0.463,0.232">
<TextBox Name="number" HorizontalAlignment="Left" Height="88" Margin="0,98,0,0"
TextWrapping="Wrap" Text="Please enter your phone number" VerticalAlignment="Top"
Width="456"/>
<TextBlock Name="bigText" HorizontalAlignment="Left" AllowDrop="True" TextWrapping="Wrap"
Text="Users will write their problem in here." VerticalAlignment="Top"
Margin="0,231,0,0" Height="414" Width="456" Foreground="White"/>
</Grid>
<Button Name="sendButton" Content="Send your problem" HorizontalAlignment="Stretch"
VerticalAlignment="Top" Margin="10,658,0,0" Grid.Row="1" BorderBrush="#FF996D6D"
Background="#FF081359"/>
Thank you in advance.
Upvotes: 0
Views: 224
Reputation: 1827
You need to replace TextBlock
. TextBlock
is only used for displaying text, so you can't edit it (eg, drop text onto it). TextBox
allows input and will let you drop text into it.
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="10,0,14,0"
RenderTransformOrigin="0.463,0.232">
<TextBox Name="number" HorizontalAlignment="Left" Height="88" Margin="0,98,0,0"
TextWrapping="Wrap" Text="Please enter your phone number" VerticalAlignment="Top"
Width="456"/>
<TextBox Name="bigText" HorizontalAlignment="Left" AllowDrop="True" TextWrapping="Wrap"
Text="Users will write their problem in here." VerticalAlignment="Top"
Margin="0,231,0,0" Height="414" Width="456" Foreground="White"/>
</Grid>
<Button Name="sendButton" Content="Send your problem" HorizontalAlignment="Stretch"
VerticalAlignment="Top" Margin="10,658,0,0" Grid.Row="1" BorderBrush="#FF996D6D"
Background="#FF081359"/>
Upvotes: 1