0

在我的应用程序中,我有一个ListBox 我已经设置它的ItemTemplate,它工作得很好。但是在遇到一些问题后,我决定将其更改ListBoxItemsControl,所以我只是将ListBox关键字更改为ItemsControl, (我不知道是否允许)。但是当我运行应用程序InvalidCastExeption时,在InitializeComponent.

我还是编程新手,所以有人可以帮我吗?

编辑:

<ListBox Name="ChannelsSearchResaultList" Visibility="Collapsed" Grid.Row="1">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Border Name="ChannelContainer" Margin="5" Width="470" 
                HorizontalAlignment="Stretch" BorderBrush="BlueViolet" 
                BorderThickness="2" Background="#FF1D1D1D" MouseLeftButtonDown=
                "Border_MouseLeftButtonDown" MouseLeftButtonUp=
                "ChannelContainer_MouseLeftButtonUp">
                <Grid Height="110">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="340"/>
                    </Grid.ColumnDefinitions>
                    <Image Source="{Binding Logo}"  Margin="5"/>
                    <TextBlock Text="{Binding Duration}"  Margin="10,5" 
                        VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
                    <Canvas Grid.Column="1" >
                        <TextBlock Text="{Binding Title}" FontWeight="Bold" 
                            Foreground="Red"/>
                        <TextBlock Text="{Binding Views}" Canvas.Top="60" 
                            Canvas.Left="20" />
                    </Canvas>
                </Grid>
            </Border>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
4

0 回答 0