TabControl中的“System.InvalidOperationException”

时间:2013-03-02 13:22:29

标签: wpf tabcontrol

<Window x:Class="AutoMerge2013.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="AutoMerge2013" Height="350" Width="525"
    Style="{StaticResource VS2012WindowStyle}">
    <TabControl x:Name="tbControl">
    <TabItem Header="Main">
        <Canvas>
            <Button Name="btnOpen" Content="Open files" Canvas.Left="40" Canvas.Top="20" Width="98" Click="btnOpen_Click_1"/>
            <Button Name="btnUpload" Content="Upload files" Canvas.Left="181" Canvas.Top="20" Width="98" Visibility="Hidden" Click="btnUpload_Click_1"/>
            <Button Name="btnMerge" Content="AutoMerge" Canvas.Left="338" Canvas.Top="20" Width="98" Visibility="Hidden" Click="btnMerge_Click_1"/>


            <StatusBar Canvas.Top="247" Width="499">
                <TextBlock x:Name="txtInfo"></TextBlock>
                <StatusBarItem HorizontalAlignment="Right">
                    <ResizeGrip />
                </StatusBarItem>
            </StatusBar>
    </TabItem>
    <TabItem Header="Original">

    </TabItem>
</TabControl>

当我点击原始标签时,它会抛出一个例外:

  

类型'System.InvalidOperationException'的未处理异常   发生在PresentationCore.dll

其他信息:指定的Visual不是此Visual的后代。

我在我的应用程序Style="{StaticResource VS2012WindowStyle}"中使用 也许这是个问题...... 你能给出一些建议如何避免这种异常并保存我的风格吗?

0 个答案:

没有答案