請幫助...我在這裏做錯了什麼?試圖將列表框綁定到數據表。調試完成後,我在表格中看到數據行,但看到它不與列表框綁定。試圖綁定數據表與列表框......錯誤的東西
僅供參考。 _this是我當前窗口的名稱...
<ListBox Grid.Column="1" ItemsSource="{Binding ElementName=_this, Path=MainCategoriesTable}" HorizontalAlignment="Center" BorderBrush="Transparent" Background="Transparent" x:Name="lbMainCategories">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<RadioButton Grid.Column="0" Content="{Binding Path=main_category_name}" VerticalAlignment="Center" GroupName="grpMainCategory" x:Name="rdbEnableDisable" />
<Label Grid.Column="1" Width="30" Background="Transparent" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
下面是財產試圖與綁定...
public DataTable MainCategoriesTable
{
get { return _dtMainCategory; }
set { _dtMainCategory = value; }
}
在哪裏控制命名爲「_this」?你不想綁定到DataContext中的某些東西嗎? – 2011-12-24 22:06:20
我也嘗試過DataContext。它也沒有工作。 _this是我的當前窗口名稱等: <窗口x:類= 「WpfApplication1.Window3」 的xmlns = 「http://schemas.microsoft.com/winfx/2006/xaml/presentation」 的xmlns:X = 「http://schemas.microsoft.com/winfx/2006/xaml」 xmlns:local =「clr-namespace:WpfApplication1」 Title =「Window3」Height =「1000」Width =「1200」 x:Name = 「_this」> 說實話。幾天前我嘗試了這個確切的代碼,它工作。我不知道我所做的更改或更改了什麼,但現在它無法正常工作...... – usergaro 2011-12-24 23:35:21