名称****在当前上下文中不存在

时间:2015-07-24 00:52:16

标签: c# wpf

名称Browser,TosBrowser和MainTabControl抛出错误。显然,它们在当前背景下并不存在。我仔细检查了MainWindow.xaml,名称是正确的。无法找出解决/修复问题的下一步。很确定我忘记打电话了。

我对WPF和c#相当新,所以任何帮助都会很精彩。 MainWindow.xaml.cs位于

之下
 public void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            Browser.Visibility = Visibility.Hidden;
            TosBrowser.Visibility = Visibility.Hidden;
            DataContext = this;
            #region ToS

            if (!Config.Instance.TosAccepted)
            {
                RightWindowCommands.Visibility = Visibility.Collapsed;
            }
            else
            {
                MainTabControl.SelectedIndex = 1;
            }

            #endregion
        }

这是MainWindow.xaml的片段

<TabControl Margin="3,-36,3,3" x:Name="MainTabControl" Grid.ColumnSpan="4" >
        <TabItem x:Name="TosTabItem" Height="36" VerticalAlignment="Top" Visibility="Visible">
            <Grid Background="#FFE5E5E5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="9*"/>
                <ColumnDefinition Width="82*"/>
            </Grid.ColumnDefinitions>
            <WebBrowser x:Name="TosBrowser" Visibility="Visible" Margin="10,10,10,32" Source="http://api.glariful.com/public/tos" Grid.ColumnSpan="2" />
            <Button Content="{DynamicResource AcceptTosButton}" HorizontalAlignment="Right" Margin="0,0,90,2" VerticalAlignment="Bottom" Width="75" Click="TosAccept_Click" Grid.Column="1"/>
            <Button Content="{DynamicResource DeclineTosButton}" Margin="0,0,10,2" HorizontalAlignment="Right" Width="75" Height="25" VerticalAlignment="Bottom" Click="TosDecline_Click" Grid.Column="1"/>
</Grid>
</TabItem>
        <TabItem x:Name="NewsTabItem" Header="News" Height="36" VerticalAlignment="Top">
            <Grid Background="#FFE5E5E5">
                <WebBrowser x:Name="Browser" Visibility="Visible" Source="http://api.glariful.com/public/news/html" Grid.ColumnSpan="2"/>

            </Grid>
        </TabItem>
        <TabItem x:Name="SettingsTabItem" Header="Settings" Height="36" VerticalAlignment="Top">
            <Grid Background="#FFE5E5E5">

            </Grid>
        </TabItem>




    </TabControl>

0 个答案:

没有答案