小编Unc*_*Ben的帖子

名称空间中不存在名称

我正在使用VS 2015中的数据模板绑定开发一个简单的UWP项目.当我尝试指定Datatemplate的类型时,我收到一个错误.

XAML:

<Page x:Name="RootPage"
x:Class="Adaptive_News_Layout.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:local="using:Adaptive_News_Layout"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" FontSize="22" >

 <SplitView x:Name="MySplitView" Grid.Row="1" DisplayMode="CompactOverlay" Background="LightGray" OpenPaneLength="200"  >
            <SplitView.Pane>
                <ListView x:Name="MyListview" ItemsSource="{x:Bind NavigationItems}"  >
                    <ListView.ItemTemplate>
                        <DataTemplate x:DataType="local:NavItem" >
                            <StackPanel Orientation="Horizontal">
                                <RelativePanel>
                                    <Button x:Name="Icon"  FontFamily="Segoe MDL2 Assets" Content="{x:Bind ButtonIcon}" Width="50" Height="50"/>
                                    <TextBlock x:Name="Section" Text="{x:Bind SectionTitle}" RelativePanel.RightOf="Icon" />
                                </RelativePanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListView.ItemTemplate>
Run Code Online (Sandbox Code Playgroud)

这是班级:

namespace Adaptive_News_Layout
{
    public class NavItem
    {
        public string ButtonIcon { get; set; }
        public string SectionTitle { get; set; }
    }
}
Run Code Online (Sandbox Code Playgroud)

错误如下:名称"NavItem"在名称空间"using:Adaptive_News_Layout"中不存在

c# datatemplate visual-studio-debugging uwp uwp-xaml

5
推荐指数
1
解决办法
2420
查看次数

将图像资源保存到 UWP 本地文件夹中的存储文件

我的 UWP 项目 ( ) 的 Assets 文件夹中有一张图像"Assets/Nophoto.jpg",我想将其另存为StorageFile应用程序的本地文件夹中。

我见过的将图像保存在 a 中的唯一方法StorageFile是使用FilePicker.

FileOpenPicker FilePicker = new FileOpenPicker();
            FilePicker.FileTypeFilter.Add(".jpeg");
            FilePicker.FileTypeFilter.Add(".png");
            FilePicker.FileTypeFilter.Add(".jpg");
            FilePicker.ViewMode = PickerViewMode.Thumbnail;
            FilePicker.CommitButtonText = "Picture";
            FilePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;

            PictureFile = await FilePicker.PickSingleFileAsync();
Run Code Online (Sandbox Code Playgroud)

我将如何将图像文件(.jpeg、.png、.bmp 等)存储在StorageFile

.net c# storage uwp

1
推荐指数
1
解决办法
2308
查看次数