请帮助...我在这里做错了什么?试图将列表框绑定到数据表。调试完成后,我在表格中看到数据行,但看到它不与列表框绑定。试图绑定数据表与列表框......错误的东西
仅供参考。 _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