名称Metrowindow不存在?

6

我遇到了一个错误:“The name metroWindow does not exist in the namespace:MahApps.Metro.Controls;assembly=MahApps.Metro”,我不知道问题出在哪里。我已经检查过使用NuGet替换了MahApps,但仍然存在同样的问题。我目前正在使用VS2012。我已经查看了一些Stack Overflow的问题,但问题仍然存在。

<controls:MetroWindow
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
       
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="DTWGestureRecognition.MainWindow"
        
        Title="Kinect Sign Language Translator" Height="900" Width="1500" Loaded="WindowLoaded" Closed="WindowClosed" Background="White">
    <Viewbox Height="768" VerticalAlignment="Top" Width="1366">
        <Border>
            <Grid Height="186" Width="2000">
                <TabControl x:Name="tabControl" Margin="-59,0,461,0">


                    <TabItem Header="Intro">
                        <Grid Margin="0,0,-527,-1053">
                            <Grid.Background>
                                <ImageBrush ImageSource="elisabet2.png"/>
                            </Grid.Background>
                        </Grid>
                    </TabItem>
                    <TabItem Header="Gesture Detection">



                        <Grid Margin="0,0,-527,-1053" Background="White">
                            <Canvas x:Name="skeletonCanvas" Background="Black" ClipToBounds="True" Margin="293,256,1186,456" Height="480"  Width="640" />
                            <Image x:Name="videoImage" Margin="953,256,526,456" Width="640" Height="480" />
                            <Image x:Name="depthImage" Grid.Column="1" HorizontalAlignment="Left" Height="12" Margin="1416,730,0,0" Grid.Row="1" VerticalAlignment="Top" Width="40" IsEnabled="False"/>






                            <StackPanel Margin="1615,257,18,691">
                                <ComboBox x:Name="gestureList" Width="486" HorizontalAlignment="Center" Height="50" Background="#FF455A64" FontSize="24" FontFamily="Arial" Foreground="White">
                                    <ComboBoxItem IsSelected="True" Content="@from"/>
                                    <ComboBoxItem Content="@go there"/>
                                    <ComboBoxItem Content="@good"/>
                                    <ComboBoxItem Content="@happy"/>
                                    <ComboBoxItem Content="@Hello."/>
                                    <ComboBoxItem Content="@in"/>
                                    <ComboBoxItem Content="@me"/>
                                    <ComboBoxItem Content="@out"/>
                                    <ComboBoxItem Content="@Please"/>
                                    <ComboBoxItem Content="@school"/>
                                    <ComboBoxItem Content="@Thank you"/>
                                    <ComboBoxItem Content="@today"/>
                                    <ComboBoxItem Content="@understand"/>
                                    <ComboBoxItem Content="@what"/>
                                    <ComboBoxItem Content="@where"/>
                                    <ComboBoxItem Content="@wrong"/>
                                    <ComboBoxItem Content="@yes"/>
                                    <ComboBoxItem Content="@you"/>
                                    <ComboBoxItem Content="@your"/>
                                </ComboBox>
                                <TextBox FontSize="24" x:Name="results" Focusable="False" BorderThickness="0" Text="" TextAlignment="Left" VerticalAlignment="Top" Height="65" Foreground="White" Background="#FF455A64" FontFamily="Arial"  />
                                <TextBox FontSize="24" x:Name="status" Focusable="False" BorderThickness="0" Text="" TextAlignment="Left" VerticalAlignment="Top" Height="65" Foreground="White" Background="#FF455A64" FontFamily="Arial" />
                                <TextBox FontSize="24" x:Name="currentBufferFrame" Focusable="False" BorderThickness="0" Text="" TextAlignment="Left" VerticalAlignment="Top" Height="65" Foreground="White" Background="#FF455A64" FontFamily="Arial" />
                            </StackPanel>


                            <StackPanel Margin="0,259,1838,452">
                                <Button x:Name="dtwRead" Content="Read" Click="DtwReadClick" Width="200" IsEnabled="False" Background="#FF455A64" Foreground="White" Height="65" FontSize="18.667"/>
                                <Button x:Name="dtwCapture" Content="Capture" Click="DtwCaptureClick" Width="200 " Background="#FF455A64" Height="65" FontSize="18.667" Foreground="White"/>
                                <!-- <Button x:Name="dtwShowGestureTest" Content="Show Gesture Text" IsEnabled="True" Click="DtwShowGestureText" Width="200"  /> -->
                                <Button x:Name="dtwStore" Content="Store" IsEnabled="False" Click="DtwStoreClick" Width="200" Background="#FF455A64" Height="65" FontSize="18.667" Foreground="White" />
                                <Button x:Name="dtwLoadFile" Content="Load gesture file" IsEnabled="True" Click="DtwLoadFile" Width="200" Margin="40,0,41,0" Height="65" Background="#FF455A64" Foreground="White" FontSize="18.667" />
                                <Button x:Name="dtwSaveToFile" Content="Save to file" IsEnabled="True" Click="DtwSaveToFile" Width="200" Margin="40,0,41,0" Height="65" Background="#FF455A64" Foreground="White" FontSize="18.667" />
                            </StackPanel>


                            <TextBox FontSize="18.667" x:Name="dtwTextOutput" Margin="1615,646,17,0" Focusable="True" BorderThickness="0" Text="" TextAlignment="Left" HorizontalAlignment="Center" VerticalAlignment="Top" Width="487" Height="414" VerticalScrollBarVisibility="Auto" IsReadOnly="True" IsEnabled="False" BorderBrush="Black" Background="White" Foreground="White" />


                            <TextBox x:Name="textBox2" Margin="293,915,526,132" TextWrapping="WrapWithOverflow" FontSize="32" Background="Black" OpacityMask="{x:Null}" VerticalContentAlignment="Center" BorderBrush="#FF7C2020" IsReadOnly="True" Foreground="White" />



                            <Label x:Name="label1_Copy" Content="COORDINATES" HorizontalAlignment="Left" Margin="1615,603,0,0" VerticalAlignment="Top" Width="486" FontSize="21.333" FontStyle="Italic" HorizontalContentAlignment="Center"/>

                            <Label x:Name="label_Copy1" Content="GESTURE SELECTOR" HorizontalAlignment="Left" Margin="1615,208,0,0" VerticalAlignment="Top" Width="486" FontSize="21.333" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontStyle="Italic"/>


                            <Label x:Name="label2" Content="SIGNS TRANSLATOR" HorizontalAlignment="Left" Margin="817,50,0,0" Width="494" VerticalAlignment="Top" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="26.667" FontStyle="Italic"/>

                            <Label x:Name="label" Content="SKELETON VIEW" HorizontalAlignment="Left" Margin="293,218,0,0" VerticalAlignment="Top" Width="640" FontSize="21.333" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontStyle="Italic" RenderTransformOrigin="0.702,0.503"/>
                            <Label x:Name="label_Copy" Content="COLOR VIEW" HorizontalAlignment="Left" Margin="953,218,0,0" VerticalAlignment="Top" Width="640" FontSize="21.333" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontStyle="Italic"/>
                            <Label x:Name="label1" Content="OUTPUT" HorizontalAlignment="Left" Margin="423,872,0,0" VerticalAlignment="Top" Width="1082" FontSize="21.333" FontStyle="Italic" HorizontalContentAlignment="Center"/>





                        </Grid>


                    </TabItem>
                    <TabItem Header="Text Detection">
                        <TabItem.Background>
                            <ImageBrush/>
                        </TabItem.Background>

                        <Grid Margin="0,0,-527,-1053">
                            <Grid.Background>
                                <ImageBrush ImageSource="website-under-construction.png" Stretch="Uniform"/>
                            </Grid.Background>
                        </Grid>


                    </TabItem>
                    <TabItem Header="Tutorial">
                        <TabItem.Background>
                            <ImageBrush/>
                        </TabItem.Background>
                        <Grid Margin="0,0,-527,-1053">
                            <Grid.Background>
                                <ImageBrush ImageSource="website-under-construction.png" Stretch="Uniform"/>
                            </Grid.Background>
                        </Grid>
                    </TabItem>
                    <TabItem Header="About Us">
                        <TabItem.Background>
                            <ImageBrush/>
                        </TabItem.Background>
                        <Grid Margin="0,0,-527,-1053">
                            <Grid.Background>
                                <ImageBrush ImageSource="website-under-construction.png" Stretch="Uniform"/>
                            </Grid.Background>
                        </Grid>
                    </TabItem>
                </TabControl>

            </Grid>

        </Border>
    </Viewbox>



</controls:MetroWindow>

2个回答

7

在我的情况下,通过基本的MahApps Nuget安装即可正常工作。因此,代码不是问题。尝试卸载MapApps Nuget,然后重新安装它,或者在Package Manager Console中运行以下命令:

Install-Package MahApps.Metro -Version 1.3.0

请记住,问题不在于你的代码,而在于你的配置。如果更新没有解决问题,请尝试删除任何可能导致问题的样式。这也有可能是一个样式问题。


1
我知道现在有点晚了,但是对于我来说只有更改 xmlns 才能解决问题。 xmlns 产生了与描述相同的错误:
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"

适用于我的 xmlns(与您使用的相同):

xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接