Ошибка XDG0008: NumberBox не поддерживается в проекте Universal Windows Platform - PullRequest
0 голосов
/ 27 января 2020

Существует странная проблема со следующим кодом:

<Page
    x:Class="FuckNumberBox.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:FuckNumberBox"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <NumberBox x:Name="BeginNumberBox"
                   Header="Enter an integer:" 
                   Value="1" 
                   SpinButtonPlacementMode="Compact" 
                   SmallChange="10"
                   LargeChange="100"/>
    </Grid>
</Page>

IDE Screenshot

После создания проекта не было внесено никаких изменений, пока я не добавил <NumberBox>. Возникают три ошибки компиляции:

Error message

Я пытаюсь обновить пакет NuGet:

NuGet Package Manager

Но ошибка все еще здесь.

Как я могу это исправить?

Мне действительно может понадобиться некоторая помощь здесь: /


Среда разработки :

  • IDE: Visual Studio 2019

    Целевая версия проекта UWP: Windows 10, версия 1903 (10.0; сборка 18362)

    проект UWP минимальная версия: Windows 10, версия 1903 (10.0; сборка 18362)

Ответы [ 2 ]

1 голос
/ 28 января 2020

Из этого документа NumberBox вы можете видеть, что NumberBox находится в пространстве имен Microsoft.UI.Xaml.Controls и применяется к WinUI. Итак, как сказал @ magicandre1981, вам нужно установить пакет Microsoft.UI.Xaml nuget и добавить ресурсы тем Windows UI (WinUI) в ваши ресурсы App.xaml. Затем добавьте пространство имен в xaml, чтобы использовать его.

App.xaml:

<Application ...>
    <Application.Resources>
        <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
    </Application.Resources>
</Application>

.xaml:

<Page
    x:Class="FuckNumberBox.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:FuckNumberBox"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    xmlns:controls="using:Microsoft.UI.Xaml.Controls">

    <Grid>
        <controls:NumberBox x:Name="BeginNumberBox"
                   Header="Enter an integer:" 
                   Value="1" 
                   SpinButtonPlacementMode="Compact" 
                   SmallChange="10"
                   LargeChange="100"/>
    </Grid>
</Page>
0 голосов
/ 01 мая 2020

Создание пользовательского элемента управления

<UserControl x:Class="GroceryPriceTracker.Controls.NumberBoxControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="using:GroceryPriceTracker.Controls"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="400">
    <UserControl.Resources>
        <x:Double x:Key="CWidth">35</x:Double>

    </UserControl.Resources>
    <Grid Height="{StaticResource CWidth}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="40"></ColumnDefinition>
            <ColumnDefinition Width="40"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <TextBox InputScope="Number" BorderThickness="1"
                 Loaded="TextBox_Loaded"
                 Padding="10,6,10,0"
                 Height="35"
                 Style="{StaticResource TextBoxStyleBlack}"></TextBox>
        <Grid Grid.Column="1"
              BorderBrush="{ThemeResource InkToolbarAccentColorThemeBrush}"
              BorderThickness="1"
              Width="{StaticResource CWidth}"
              Height="{StaticResource CWidth}">
            <Button Width="{StaticResource CWidth}"
                    Height="{StaticResource CWidth}"
                    Grid.Column="1"
                    BorderThickness="0"
                    Background="Transparent">
                <FontIcon FontSize="17"
                          FontFamily="Segoe MDL2 Assets"
                          Glyph="&#xE010;" />
            </Button>
        </Grid>
        <Grid Grid.Column="2"
              Margin="-5,0,0,0"
              BorderBrush="{ThemeResource InkToolbarAccentColorThemeBrush}"
              BorderThickness="1"
              Width="{StaticResource CWidth}"
              Height="{StaticResource CWidth}">
            <Button Width="{StaticResource CWidth}"
                    Height="{StaticResource CWidth}"
                    BorderThickness="0"
                    Background="Transparent"
                    Grid.Column="2">
                <FontIcon FontSize="17"
                          FontFamily="Segoe MDL2 Assets"
                          Glyph="&#xE09D;" />
            </Button>
        </Grid>

    </Grid>
</UserControl>

...