这是我的xaml.cs文件,
public class k_array
{
public String Fitment { get; set; }
public String Part { get; set; }
public String Nrb { get; set; }
public String Dimension { get; set; }
public String No_off { get; set; }
public k_array(String fitment, String part, String nrb, String dimension, String no_off)
{
this.Fitment = fitment;
this.Part = part;
this.Nrb = nrb;
this.Dimension = dimension;
this.No_off = no_off;
}
}
public class K_arrays : ObservableCollection<k_array>
{
public K_arrays()
{
Add(new k_array("Michael", "Anderberg",
"12 North Third Street, Apartment 45","",""));
Add(new k_array("Chris", "Ashton",
"34 West Fifth Street, Apartment 67","",""));
Add(new k_array("Cassie", "Hicks",
"56 East Seventh Street, Apartment 89","",""));
Add(new k_array("Guido", "Pica",
"78 South Ninth Street, Apartment 10","",""));
}
}
用我的.xaml代码编写的代码, 我已经在列表框中编写了文本块 试图从我的.cs文件中获取K_arrays的资源
<Grid x:Name="listView4">
<ListView x:Name="testgrid" ItemsSource="{Binding}">
<TextBlock x:Name="T1"> </TextBlock>
<TextBlock x:Name="T2"></TextBlock>
<TextBlock x:Name="T3"></TextBlock>
<ListBox ItemsSource="{StaticResource K_arrays}" Width="350" Margin="0,5,0,10">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Padding="5,0,5,0" Text="{Binding Fitment}" />
<TextBlock Text="{Binding Part}" />
<TextBlock Text="{Binding Nrb}" />
<TextBlock Text="{Binding Dimension}" />
<TextBlock Text="{Binding No_off}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ListView>
</Grid>
错误:找不到名称/密钥K_arrays的资源[行:35位置:34] 我也更改了.cs文件并将其发布了