在ListBox中,如果要用path方式,除了对ListBox本身做设置之外,还需要对它的项目进行设置。
请将以下内容
<ListBox x:Name="macroList" HorizontalAlignment="Left"
Height="664" VerticalAlignment="Bottom"
DisplayMemberPath="macroName" SelectedValuePath="ID"
Margin="5,10,5,10" />
改为:
<ListBox x:Name="macroList" HorizontalAlignment="Left"
Height="664" VerticalAlignment="Bottom"
DisplayMemberPath="macroName" SelectedValuePath="ID"
Margin="5,10,5,10" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>