我已经设置了ListBox的ItemsSource,如下所示:
<ListBox ItemsSource="{Binding abc}" />
Run Code Online (Sandbox Code Playgroud)
我想要的是
<ListBox>
<listBox.ItemsSource>
?????????????
<listBox.ItemsSource>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
<Window xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<ListBox>
<ListBox.ItemsSource>
<x:Array Type="sys:String">
<sys:String>1st item</sys:String>
<sys:String>2nd item</sys:String>
</x:Array>
<ListBox.ItemsSource>
</ListBox>
</Window>
Run Code Online (Sandbox Code Playgroud)
<ListBox>
<listBox.ItemsSource>
<Binding Path = "abs" />
<listBox.ItemsSource>
</ListBox>
Run Code Online (Sandbox Code Playgroud)