[英]Property error in Windows phone development in C# and XAML
這是2014年的水上黑客馬拉松項目。 我是Windows Phone的新手。 我正在為一個項目開發一個應用程序。 該應用程序的一部分是,用戶將輸入他的電話號碼和一些文本,並將該數字和文本通過電子郵件發送給特定的人。 我使用了拖放UI,並在Visual C#中編寫了電子郵件發送代碼。 這是錯誤:
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()
C#代碼的一部分:
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:","ibtehaz.shawon@gmail.com"),
// 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();
}
XAML文件的一部分:
<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"/>
先感謝您。
您需要替換TextBlock
。 TextBlock
僅用於顯示文本,因此您無法對其進行編輯(例如,將文本拖放到其上)。 TextBox
允許輸入,並允許您將文本放入其中。
<!--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"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.