';ListViewItem';不包含接受1个参数的构造函数,Windows phone c#

';ListViewItem';不包含接受1个参数的构造函数,Windows phone c#,c#,listview,windows-phone,C#,Listview,Windows Phone,您好,我正在尝试向listview添加项,但出现以下错误,“ListViewItem”不包含接受1个参数的构造函数。 我在新ListViewItem(行)中遇到错误; 我正在c#中使用Windows phone 8.1 您正在将字符串作为参数发送到listviewtem。ListViewItem具有content属性 你喜欢这样吗 listView.Items.Add(new ListViewItem{Content = whateveryourstring}); 您正在将字符串作为参数发送到

您好,我正在尝试向listview添加项,但出现以下错误,“ListViewItem”不包含接受1个参数的构造函数。 我在新ListViewItem(行)中遇到错误; 我正在c#中使用Windows phone 8.1


您正在将字符串作为参数发送到listviewtem。ListViewItem具有content属性

你喜欢这样吗

listView.Items.Add(new ListViewItem{Content = whateveryourstring});

您正在将字符串作为参数发送到listviewtem。ListViewItem具有content属性

你喜欢这样吗

listView.Items.Add(new ListViewItem{Content = whateveryourstring});

我认为您是基于xaml的
System.Windows.Forms.ListViewItem
(它有一个用于获取字符串数组的构造函数)的
System.Windows.Controls.ListViewItem

您可以用另一种方式使用后者:

XAML:

编辑:

如果GridView不是您的选项,并且您希望/必须自己将所有东西都放好,您可以使用以下方法(基于):


我认为您是基于xaml的
System.Windows.Forms.ListViewItem
(它有一个用于获取字符串数组的构造函数)的
System.Windows.Controls.ListViewItem

您可以用另一种方式使用后者:

XAML:

编辑:

如果GridView不是您的选项,并且您希望/必须自己将所有东西都放好,您可以使用以下方法(基于):


我认为您需要添加一个具有要在视图中显示的属性的类。 像这样

public class ListModel {
    public string TotalQuantity { set; get; }
    public string Name { set; get; }
}
然后试试这个XAML

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

<toolkit:ListView Name="listView">
    <toolkit:ListView.ItemTemplate>
       <DataTemplate>
           <Grid>
               <Grid.ColumnDefinitions>
                   <ColumnDefinition Width="100" />
                   <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>                       
                <TextBlock  Text="{Binding TotalQuantity}" />
                <TextBlock Grid.Column="1" Text="{Binding Name}" />
           </Grid>
       </DataTemplate>
   </toolkit:ListView.ItemTemplate>
</toolkit:ListView>
xmlns:toolkit=“clr命名空间:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.toolkit”
最后为列表视图添加itemsource

int totalq = int.Parse("3") + 2;
textBox.Text = totalq.ToString();
double totalvanilla = Convert.ToDouble(totalq) * 1.50;
textBox_Copy.Text = totalvanilla.ToString();
listBox.Items.Add(totalq.ToString() + "Vanilla");

ListViewItems = new ObservableCollection<ListModel>();
ListViewItems.Add(new ListModel()
{
    TotalQuantity = totalq.ToString(),
     Name = "vanilla"
});
listView.ItemsSource = ListViewItems;
inttotalq=int.Parse(“3”)+2;
textBox.Text=totalq.ToString();
双倍总计=换算为双倍(总计Q)*1.50;
textBox_Copy.Text=totalvanilla.ToString();
添加(totalq.ToString()+“香草”);
ListViewItems=新的ObservableCollection();
添加(新的ListModel()
{
TotalQuantity=totalq.ToString(),
Name=“香草”
});
listView.ItemsSource=ListViewItems;

我认为您需要添加一个具有要在视图中显示的属性的类。 像这样

public class ListModel {
    public string TotalQuantity { set; get; }
    public string Name { set; get; }
}
然后试试这个XAML

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

<toolkit:ListView Name="listView">
    <toolkit:ListView.ItemTemplate>
       <DataTemplate>
           <Grid>
               <Grid.ColumnDefinitions>
                   <ColumnDefinition Width="100" />
                   <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>                       
                <TextBlock  Text="{Binding TotalQuantity}" />
                <TextBlock Grid.Column="1" Text="{Binding Name}" />
           </Grid>
       </DataTemplate>
   </toolkit:ListView.ItemTemplate>
</toolkit:ListView>
xmlns:toolkit=“clr命名空间:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.toolkit”
最后为列表视图添加itemsource

int totalq = int.Parse("3") + 2;
textBox.Text = totalq.ToString();
double totalvanilla = Convert.ToDouble(totalq) * 1.50;
textBox_Copy.Text = totalvanilla.ToString();
listBox.Items.Add(totalq.ToString() + "Vanilla");

ListViewItems = new ObservableCollection<ListModel>();
ListViewItems.Add(new ListModel()
{
    TotalQuantity = totalq.ToString(),
     Name = "vanilla"
});
listView.ItemsSource = ListViewItems;
inttotalq=int.Parse(“3”)+2;
textBox.Text=totalq.ToString();
双倍总计=换算为双倍(总计Q)*1.50;
textBox_Copy.Text=totalvanilla.ToString();
添加(totalq.ToString()+“香草”);
ListViewItems=新的ObservableCollection();
添加(新的ListModel()
{
TotalQuantity=totalq.ToString(),
Name=“香草”
});
listView.ItemsSource=ListViewItems;

当我运行程序时,它会告诉我system.string,知道为什么吗?当我运行程序时,它会告诉我system.string,知道为什么吗?windows phone 8.1中不存在Gridview列。当我使用这个方法时,它显示了一个错误。谢谢你,这救了我!windows phone 8.1中不存在Gridview列。当我使用这个方法时,它显示了一个错误。谢谢你,这救了我!请在要使用listview数据的位置添加listview xaml代码请在要使用listview数据的位置添加listview xaml代码