如何将 Platform::Collections::Vector 绑定到 gridview
How to bind Platform::Collections::Vector to a gridview
我正在尝试将 Platform::Collections::Vector 绑定到 GridView,但我收到 Visual Studio:
的编译时错误
C3986 'get':the signature of the public member contains a native type 'std::equal_to<T>'
C3986 'get':the signature of the public member contains a native type 'std::equal_to<T>'
C3986 'get':the signature of the public member contains a native type 'std::equal_to<T>'
C3986 'get':the signature of the public member contains a native type 'std::equal_to<T>'
NavigationPage.xaml.h
[Windows::Foundation::Metadata::WebHostHidden]
public ref class NavigationPage sealed
{
public:
NavigationPage();
property Platform::Collections::Vector<Platform::String^>^ ImagesProperty
{
Platform::Collections::Vector<Platform::String^>^ get()
{
if (Images == nullptr) Images = ref new Platform::Collections::Vector<Platform::String^>();
return this->Images;
};
}
private:
Platform::Collections::Vector<Platform::String^>^ Images;
};
NavigationPage.xaml
<GridView Grid.Row="1" x:Name="View" ItemSource="{x:Bind ImagesProperty}">
<GridView.ItemTemplate>
<DataTemplate>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
我已经尝试在 Google 上搜索,但我发现的大多数示例都是用 C# 制作的,如果对于 C++,它们的目标是 Windows 8/8.1,所以作为最后一个资源,我决定询问这里。
目标版本:10586,最低版本:10586
对于那些可能遇到我同样问题的人,这里是代码,多亏了 link Ed Plunkett 发布,我才能够让它工作,问题是 class Platform::Collections::Vector(详情在他link)
public:
NavigationPage();
property Windows::Foundation::Collections::IObservableVector<Platform::String^>^ ImagesProperty
{
Windows::Foundation::Collections::IObservableVector<Platform::String^>^ get()
{
if (Images == nullptr) Images = ref new Platform::Collections::Vector<Platform::String^>();
return Images;
}
}
private:
Platform::Collections::Vector<Platform::String^>^ Images;
};
如您所见,我隐式地将 Vector class 转换为 IObservableVector
我正在尝试将 Platform::Collections::Vector 绑定到 GridView,但我收到 Visual Studio:
的编译时错误C3986 'get':the signature of the public member contains a native type 'std::equal_to<T>'
C3986 'get':the signature of the public member contains a native type 'std::equal_to<T>'
C3986 'get':the signature of the public member contains a native type 'std::equal_to<T>'
C3986 'get':the signature of the public member contains a native type 'std::equal_to<T>'
NavigationPage.xaml.h
[Windows::Foundation::Metadata::WebHostHidden]
public ref class NavigationPage sealed
{
public:
NavigationPage();
property Platform::Collections::Vector<Platform::String^>^ ImagesProperty
{
Platform::Collections::Vector<Platform::String^>^ get()
{
if (Images == nullptr) Images = ref new Platform::Collections::Vector<Platform::String^>();
return this->Images;
};
}
private:
Platform::Collections::Vector<Platform::String^>^ Images;
};
NavigationPage.xaml
<GridView Grid.Row="1" x:Name="View" ItemSource="{x:Bind ImagesProperty}">
<GridView.ItemTemplate>
<DataTemplate>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
我已经尝试在 Google 上搜索,但我发现的大多数示例都是用 C# 制作的,如果对于 C++,它们的目标是 Windows 8/8.1,所以作为最后一个资源,我决定询问这里。
目标版本:10586,最低版本:10586
对于那些可能遇到我同样问题的人,这里是代码,多亏了 link Ed Plunkett 发布,我才能够让它工作,问题是 class Platform::Collections::Vector(详情在他link)
public:
NavigationPage();
property Windows::Foundation::Collections::IObservableVector<Platform::String^>^ ImagesProperty
{
Windows::Foundation::Collections::IObservableVector<Platform::String^>^ get()
{
if (Images == nullptr) Images = ref new Platform::Collections::Vector<Platform::String^>();
return Images;
}
}
private:
Platform::Collections::Vector<Platform::String^>^ Images;
};
如您所见,我隐式地将 Vector class 转换为 IObservableVector