未找到元素“<stackpanel>”的关闭标记错误消息</stackpanel>

时间:2015-01-03 18:54:48

标签: c# wpf

任何人都知道,为什么我会收到此错误:&#34;关闭元素标签&#39; StackPanel&#39;找不到&#34;

对于此代码:

<Window x:Class="BiztositasFeladat.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded_1">
    <Grid>
        <Button Content="New" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
        <Button Content="Stat" HorizontalAlignment="Left" Margin="229,289,0,0" VerticalAlignment="Top" Width="75"/>
        <ListBox x:Name="listBox" HorizontalAlignment="Left" Height="249" Margin="10,35,0,0" VerticalAlignment="Top" Width="497">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <Label Content="{Binding Type}"/>
                        <Label Content="{Binding Name}"/>
                        <Label Content="{Binding Date}"/>
                        <Label Content="{Binding Amount}"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

    </Grid>
</Window>

1 个答案:

答案 0 :(得分:1)

重新启动visual studio,然后重建。有时xaml编辑器卡住了,但我真的不知道为什么。无论如何,这种解决方法对我有用了几次