阅读背景:

WPF ListBox ItemsSource StaticResource / Binding问题

来源:互联网 

Given the following code:

给出以下代码:

<Window x:Class="WpfApplication76.Window1"
    xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:col="clr-namespace:System.Collections;assembly=mscorlib"
    Title="Window1" Height="300" Width="300">

    <Window.Resources>
        <CollectionViewSource x:Key="myCol">
            <CollectionViewSource.Source>
                <col:ArrayList>
                    <ListBoxItem>Uno</ListBoxItem>
                    <ListBoxItem>Dos</ListBoxItem>
                    <ListBoxItem>Tres</ListBoxItem>
                </col:ArrayList>
            </CollectionViewSource.Source>
        </CollectionViewSource>
    </Window.Resources>

    <Grid>
        <ListBox ItemsSource="{StaticResource myCol}" />
        <ListBox ItemsSource="{Binding Source={StaticResource myCol}}" />
    </Grid>

</Window>
<Window x



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: