C# 这是我的XAML代码,它有第41行及其位置252
我一直在开发一个Windows Phone应用程序,它将图像和文本一起拍摄并上传到服务器C# 这是我的XAML代码,它有第41行及其位置252,c#,windows-phone-7,C#,Windows Phone 7,我一直在开发一个Windows Phone应用程序,它将图像和文本一起拍摄并上传到服务器 调试应用程序时出现问题。这个问题似乎是技术性的。我真的不知道该怎么办 这就是为什么我想在这里发布这些问题。如果你们中有人能帮助解决这个问题,我将非常感谢你们在这里给我的帮助 我真的很感激这里所做的工作。如果没有你们,我们真的不会走这么远。你给了我们从错误中学习的机会 再次感谢 请检查我的代码是否需要调整 以下是我在Emulator上调试时弹出的错误消息: 未能分配到属性“System.Windows.Con
调试应用程序时出现问题。这个问题似乎是技术性的。我真的不知道该怎么办 这就是为什么我想在这里发布这些问题。如果你们中有人能帮助解决这个问题,我将非常感谢你们在这里给我的帮助 我真的很感激这里所做的工作。如果没有你们,我们真的不会走这么远。你给了我们从错误中学习的机会 再次感谢 请检查我的代码是否需要调整 以下是我在Emulator上调试时弹出的错误消息: 未能分配到属性“System.Windows.Controls.Primitives.ButtonBase.Click”。[第41行位置:250] 不幸的是,这是我的第一篇帖子,所以我不能发布图片 我感谢这里所做的工作
private void button3_Click(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
//void photoChooserTask_Completed(object sender, PhotoResult e)
//{
{
System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
bmp.SetSource(e.ChosenPhoto);
image1.Source = bmp;
byte[] sbytedata = ReadToEnd(e.ChosenPhoto);
string s = sbytedata.ToString();
WebClient wc = new WebClient();
Uri u = new Uri("ftp://ftp.icupload.cs201.com/icupload.cs201.com/images/");
wc.OpenWriteCompleted += new OpenWriteCompletedEventHandler(wc_OpenWriteCompleted);
wc.OpenWriteAsync(u, "POST", sbytedata);
}
}
public static void wc_OpenWriteCompleted(object sender, OpenWriteCompletedEventArgs e)
{
if (e.Error == null)
{
object[] objArr = e.UserState as object[];
byte[] fileContent = e.UserState as byte[];
Stream outputStream = e.Result;
outputStream.Write(fileContent, 0, fileContent.Length);
outputStream.Flush();
outputStream.Close();
string s = e.Result.ToString(); ;
}
}
public static byte[] ReadToEnd(System.IO.Stream stream)
{
long originalPosition = stream.Position;
stream.Position = 0;
try
{
byte[] readBuffer = new byte[4096];
int totalBytesRead = 0;
int bytesRead;
while ((bytesRead = stream.Read(readBuffer, totalBytesRead, readBuffer.Length - totalBytesRead)) > 0)
{
totalBytesRead += bytesRead;
if (totalBytesRead == readBuffer.Length)
{
int nextByte = stream.ReadByte();
if (nextByte != -1)
{
byte[] temp = new byte[readBuffer.Length * 2];
Buffer.BlockCopy(readBuffer, 0, temp, 0, readBuffer.Length);
Buffer.SetByte(temp, totalBytesRead, (byte)nextByte);
readBuffer = temp;
totalBytesRead++;
}
}
}
byte[] buffer = readBuffer;
if (readBuffer.Length != totalBytesRead)
{
buffer = new byte[totalBytesRead];
Buffer.BlockCopy(readBuffer, 0, buffer, 0, totalBytesRead);
}
return buffer;
}
finally
{
stream.Position = originalPosition;
}
}
这是第41行。。。位置252是“单击=我的按钮3\u单击”
在您提到的所有更改之后,我仍然会遇到三个相同的错误
错误2“System.Windows.RoutedEventArgs”不包含“ChosenPhoto”的定义,并且找不到接受“System.Windows.RoutedEventArgs”类型的第一个参数的扩展方法“ChosenPhoto”(是否缺少using指令或程序集引用?)C:\Users\Yaseen\Desktop\IC Final\Phone Application\MainPage.xaml.cs 107 41 Phone Application
这些直接出现在button3语法之后我认为您发布的代码与错误消息无关 但你的问题似乎和我一样
当codebehind只有
按钮3\u单击时,您将XAML中的单击设置为myButton3\u单击
这些应该是匹配的。问题不在您发布的代码中,而在您的XAML中,因此您得到的XAMLParse错误。您可以发布相应XAML的第41行(以及前后几行)。+1是的,button3\u Click
的签名肯定应该是RoutedEventArgs e
,而不是PhotoResult e
。我真的不知道如何解决这个问题。+1,但请将XAML修改为Button2\u Click
。而且代码背后的签名也不正确。
<Button BorderBrush="#FFFF7300" Content="Capture Photo" FontSize="22" Foreground="#FFFF7300" Height="78" Margin="263,23,-10,0" Name="myButton" VerticalAlignment="Top" Click="button2_Click" FontFamily="Tahoma" BorderThickness="4" />
<Image Height="275" HorizontalAlignment="Left" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="269" />
<Button Content="Comment & Location" Height="72" HorizontalAlignment="Left" Margin="92,599,0,0" Name="button1" VerticalAlignment="Top" Width="294" Foreground="#FFFF7300" OpacityMask="#FFFF7300" BorderBrush="#FF091A08" FontFamily="Tahoma" FontWeight="Normal" Background="Transparent" Click="button1_Click" />
<Button Content="Select Photo" HorizontalAlignment="Left" Margin="264,107,0,0" Name="button2" Width="202" FontSize="24" Foreground="#FFFF7300" FontFamily="Tahoma" Background="Transparent" BorderBrush="#FFFF7300" BorderThickness="4" Height="78" VerticalAlignment="Top" Click="button2_Click_1" />
<Button Content="Upload" Height="84" HorizontalAlignment="Left" Margin="272,191,0,0" Name="myButton3" VerticalAlignment="Top" Width="186" BorderBrush="#FFFF7300" BorderThickness="4" FontFamily="Tahoma" FontSize="26" Foreground="#FFFF7300" Click="myButton3_Click" ClickMode="Release" DataContext="{Binding}" />
<TextBlock Height="200" HorizontalAlignment="Left" Margin="28,290,0,0" Name="textBlock1" Text="" VerticalAlignment="Top" Width="400" FontSize="30" TextTrimming="WordEllipsis" TextWrapping="Wrap" />