Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio Silverlight用户控件在设计器中消失_Visual Studio_Silverlight_Xaml - Fatal编程技术网

Visual studio Silverlight用户控件在设计器中消失

Visual studio Silverlight用户控件在设计器中消失,visual-studio,silverlight,xaml,Visual Studio,Silverlight,Xaml,我正在用Silverlight编写一个应用程序,它应该从Google检索天气数据,然后显示出来。我正在用XAML处理布局,打算看看它在设计器中的外观,但当我切换到设计器窗格时,一个小通知说程序集已更新,所以我单击它,用户控件消失了!我一直在尝试删除最近标记的一部分,但似乎没有帮助。以下是主要用户控件的XAML: <UserControl x:Class="TestApp2.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xa

我正在用Silverlight编写一个应用程序,它应该从Google检索天气数据,然后显示出来。我正在用XAML处理布局,打算看看它在设计器中的外观,但当我切换到设计器窗格时,一个小通知说程序集已更新,所以我单击它,用户控件消失了!我一直在尝试删除最近标记的一部分,但似乎没有帮助。以下是主要用户控件的XAML:

<UserControl x:Class="TestApp2.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:wtb="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Extended"
    xmlns:local="clr-namespace:TestApp2"
    Width="400" Height="300">

    <Grid x:Name="LayoutRoot" Background="#FF5e59e4">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Border Grid.Row="0" Grid.Column="0" Margin="5" CornerRadius="5" Background="AliceBlue">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="100" />
                    <ColumnDefinition Width="70" />
                </Grid.ColumnDefinitions>

                <Border Grid.Row="0" Grid.Column="0" Margin="3" Style="{StaticResource RoundedBox}" >
                    <TextBlock x:Name="TextBox" Text="Weather Finder" Margin="5,0,0,0" FontSize="18" VerticalAlignment="Center"/>
                </Border>
                <wtb:WatermarkedTextBox Grid.Row="0" Grid.Column="1" Watermark="City..." Margin="2,4,2,4" />
                <Button x:Name="SearchButton" Grid.Row="0" Grid.Column="3" Content="Search" VerticalAlignment="Center" Margin="2,0,2,0" />

                <!--<ListBox x:Name="DataList" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Margin="3,0,3,3" />-->

                <StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Margin="3,0,3,3" Orientation="Vertical">
                    <local:WeatherBox x:Name="Cur" HorizontalAlignment="Center" />

                    <StackPanel Orientation="Horizontal">
                        <local:WeatherBox x:Name="Day1" HorizontalAlignment="Center" />
                        <local:WeatherBox x:Name="Day2" HorizontalAlignment="Center" />
                        <local:WeatherBox x:Name="Day3" HorizontalAlignment="Center" />
                        <local:WeatherBox x:Name="Day4" HorizontalAlignment="Center" />

                    </StackPanel>
                </StackPanel>
            </Grid>
        </Border>

    </Grid>
</UserControl>

我还没有在应用程序中写入任何功能,所以这不会是问题所在。我相信这可能与我自己的WeatherBox有关(如果有人想看到它的代码,请说出来),但将它们从代码中删除是行不通的。有什么不对劲吗

我想我可能已经发现了问题的一个原因。WeatherBox控件中的这行XAML在我运行应用程序时出现异常:

<BitmapImage UriSource="{Binding Thumbnail, Converter={StaticResource BitmapImageConverter}}" />


据我所知,不可能直接在URI源中使用绑定,所以我尝试使用转换器。它似乎在编辑器中工作,但在运行时不起作用。我仍然不知道出了什么问题。

在您设计的自定义控件中,这种情况经常发生。目前,VisualStudioDesigner的支持非常脆弱(VisualStudio2008的silverlight 2&3测试版)。它会对一点小事发怒,永远不会告诉你为什么。至少你没有收到COM错误

找出导致它的控件的最简单方法是开始注释XAML的片段,直到通过消除来识别该控件

通常,它是您自己的控件之一,之所以这样做是因为您试图从网站或web服务下载一些数据,而这在designer模式下是无法做到的。您所需要做的就是检测它是否处于设计模式,如果处于设计模式,则跳过代码

这是一种后邻接检测设计模式:


绑定错误不是原因,尽管它不应该被忽略。这意味着您绑定到的对象没有您尝试访问的属性。

是否还有其他消息?在错误列表中?是的,有。“未声明的前缀[第18行,位置55]”,但我认为这行没有错。这是第二个网格声明。同样,错误显示为第18行和第55位,但在错误列表中它位于第1行的第1位。奇怪。我已经试着从主控移除了风箱控制,除了我不知道是什么原因造成的。我还没有编写下载天气数据的代码,所以我被难住了。除了基本网格,我已经注释掉了我所有的Xaml,但它仍然不起作用。