2013-02-03 56 views
0

我有一個列表視圖項我如何填充在2列列表視圖從2個陣列在WPF C#

(XAML)

<ListView Name="myListView" BorderThickness="2,2,2,2" Margin="12,27,428,12"> 
     <ListView.View> 
      <GridView> 
       <GridViewColumn Width="150" Header="Column1" DisplayMemberBinding="{Binding Test1}"/> 
       <GridViewColumn Width="150" Header="Column2" DisplayMemberBinding="{Binding Test2}"/> 
      </GridView> 
     </ListView.View> 
     <ListViewItem> 
     </ListViewItem> 
    </ListView> 

而想用2個不同的陣列

string[] ApplicationNames 
string[] ClassNames 
來填補它

但我很難這樣做。任何人都可以將我指向正確的方向嗎?

我使用WPF

回答

1

的回答你的問題可能會被發現here

P.S.如果您正在XAML中開發UI,那麼您正在開發WPF Application而不是Winforms。通過在Visual Studio中選擇項目類型時選擇Windows Forms Application來創建Winforms應用程序。

+0

也感謝解釋WPF和WinForms之間的區別! –

+0

沒問題,祝你好運。 – Mash

0

XAML:

<ListView Name="ResultListView"> 
     <ListView.View> 
      <GridView> 
       <GridViewColumn Width="Auto" DisplayMemberBinding="{Binding ApplicationName }" Header="File" /> 
       <GridViewColumn Width="Auto" DisplayMemberBinding="{Binding ClassName }"  Header="Location" /> 
      </GridView> 
     </ListView.View> 
</ListView> 

MyObject.cs

class MyObject 
{ 
    public string ApplicationName { get; set; } 
    public string ClassName { get; set; } 
} 

ObservableCollection<MyObject> results = new ObservableCollection<MyObject>(); 
//Populate some data into results here 
ResultListView.ItemsSource =results;