C# 声明类型错误中缺少部分修饰符

C# 声明类型错误中缺少部分修饰符,c#,visual-studio-2008,expression-blend,C#,Visual Studio 2008,Expression Blend,我是新的表达融合。在开发桌面应用程序时,我遇到了一个错误,错误是“声明类型缺少部分修饰符”,但我已通过将partial关键字放在public和class之间进行了更正。更正后,我得到了下面的错误,如果您能为这些错误提供适当的解决方案,我将不胜感激 The name 'startPoint' does not exist in the current context C:\Documents and Settings\acer\Desktop\my inter\rrrr\dragDrop(te

我是新的表达融合。在开发桌面应用程序时,我遇到了一个错误,错误是“声明类型缺少部分修饰符”,但我已通过将
partial
关键字放在public和class之间进行了更正。更正后,我得到了下面的错误,如果您能为这些错误提供适当的解决方案,我将不胜感激

The name 'startPoint' does not exist in the current context C:\Documents and Settings\acer\Desktop\my inter\rrrr\dragDrop(test1)\dragDrop(test1)\Window1.xaml.cs 24 9 dragDrop(test1)
要解决第一个错误,请添加这个类成员:(只需在任何方法之外的顶部声明它)

Point startPoint=Point.Empty

第二个错误更棘手。。据我所见,
IndexFromContainer
方法返回整数,但假设
listViewItem
已经是
Contact
类型,请尝试将行更改为:

Contact contact = (Contact)listViewItem;
看起来您缺少
联系人
类的定义。。找不到任何标准,但我想你是说这个班

public class Contact
{
    public Contact()
    {
    }

    public string Name
    {
        get;
        set;
    }

    public string Email
    {
        get;
        set;
    }

    public string PhoneNumber
    {
        get;
        set;
    }
}

请从“Window1.xaml.cs”文件中发布相关代码。在第24行和第67行附近张贴代码。私有无效列表_预览鼠标左键向下(对象发送者,鼠标按钮文本目标e){startPoint=e.GetPosition(null);}私有无效列表_鼠标移动(对象发送者,鼠标文本目标e){Vector diff=startPoint-mousePos;Contact Contact=(Contact)listView.ItemContainerGenerator.IndexFromContainer(listViewItem);DataObject dragData=new DataObject(“myFormat”,Contact);{private void DropList_Drop(object sender,DragEventArgs e){listView.Items.Add(Contact);}}第二个错误仍然存在。第一个错误已通过将线更改为Point startPoint=Point()进行更正;非常感谢您的回答。我只想编写一个程序,允许用户将一个网格视图中的图像拖放到另一个网格视图中。即使我做了上述修改,错误仍然存在。抱歉,我没有主意。听起来您没有正确使用Expression Blend,请尝试使用一些工作示例并开始从这里开始。提供的答案是正确的。非常感谢。是否可以编写一个程序,允许用户在给定图片数量时将图像拖放到适当的位置。例如:在开发学习oop的电子学习工具时,为了演示“继承性”我已经设计了一个使用expression blend的活动。一个图形层次结构将提供一些空白。就像带有一些空白的家谱。将提供适当的图片。我想编写一个程序,允许用户将正确的图片拖放到正确的位置。你能给我一个示例演示代码或图特吗。谢谢你,这It’最好被当作新问题来问。
private void List_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    startPoint = e.GetPosition(null);
}

private void List_MouseMove(object sender, MouseEventArgs e)
{
    Vector diff = startPoint - mousePos;
    Contact contact = (contact)listView.ItemContainerGenerator.IndexFromContainer(listViewItem);
    DataObject dragData = new DataObject("myFormat", contact);
}

private void DropList_Drop(object sender, DragEventArgs e)
{
    listView.Items.Add(contact);
}
Point startPoint = new Point();
Contact contact = (Contact)listViewItem;
public class Contact
{
    public Contact()
    {
    }

    public string Name
    {
        get;
        set;
    }

    public string Email
    {
        get;
        set;
    }

    public string PhoneNumber
    {
        get;
        set;
    }
}