我正在尝试设置Margin我的Ellipse代码.我如何设置Margin的 p?
auto p = ref new Windows::UI::Xaml::Shapes::Ellipse();
p->Height=100.0;
p->Width=100.0;
//p->Margin="36,19,0,0";
auto t = ref new Windows::UI::Xaml::Thickness(10.0,20.0,30.0,40.0);
Run Code Online (Sandbox Code Playgroud) 我有一个头文件定义了我想在我的代码中使用的一些结构.
public value struct HttpHeader
{
Platform::String^ mName;
Platform::String^ mValue;
};
typedef Platform::Collections::Vector<HttpHeader> HttpHeaders;
public value struct HttpRequestEvent
{
Platform::String^ mUri;
HttpHeaders^ mHeaders;
};
Run Code Online (Sandbox Code Playgroud)
当我构建这个时,我收到此错误:
error C3986: 'mHeaders': signature of public member contains native type 'std::equal_to<_Ty>'
with
[
_Ty=cpcpb::HttpHeader
] (SettingsServiceImpl.cpp)
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?不是我使用C++/Cx的一切吗?
我真的不明白在C++/CX中shared_ptr和新句柄符号(^)之间的区别.根据我的阅读,他们似乎在引用计数和内存管理方面做同样的事情.我错过了什么?
std::shared_ptr<Type>
//vs
Type^
Run Code Online (Sandbox Code Playgroud) 根据用例,我的印象是对WinRT对象的引用计数是线程安全的.但我遇到了一个我不知道其他任何解释方式的错误.例如,以下代码崩溃很快:
ref class C sealed {
public:
C() { }
virtual ~C() {}
};
[Windows::Foundation::Metadata::WebHostHidden]
public ref class MainPage sealed {
public:
MainPage() : _latest(nullptr) {
InitializeComponent();
Windows::System::Threading::ThreadPool::RunAsync(
ref new Windows::System::Threading::WorkItemHandler(
this,
&MainPage::SetLatest));
Windows::System::Threading::ThreadPool::RunAsync(
ref new Windows::System::Threading::WorkItemHandler(
this,
&MainPage::OnRendering));
}
virtual ~MainPage(){}
private:
C^ _latest;
void SetLatest(Windows::Foundation::IAsyncAction^ operation){
while (true) {
_latest = ref new C();
}
}
void OnRendering(Windows::Foundation::IAsyncAction^ operation) {
while (true) {
auto c = _latest;
}
}
};
Run Code Online (Sandbox Code Playgroud)
C^当读/写比赛时,WinRT指针(即类似的ref类)是否应该被正确引用?是否有一个我不知道的单独问题,造成这次崩溃?
我正在按照本指南进行操作,并且我正在使用包含该术语的代码的这些部分[this](只需按Ctrl-F就可以了;您将看到我的意思).
我不确定这是C++的东西还是C++/CX的东西,不管怎样,我不知道它是什么.
它是什么?
我试图从这个答案中放入类NativeBuffer 但是当windows.storage.streams.h我有很多错误,如:
Error 1 error C2872: 'AsyncStatus' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 75
Error 2 error C2872: 'AsyncStatus' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 76
Error 3 error C2872: 'AsyncStatus' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 77
Error 4 error C2872: 'AsyncStatus' : ambiguous symbol c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 78
Error 5 error C2371: 'IAsyncInfo' : redefinition; different basic types c:\program files (x86)\windows phone kits\8.0\include\abi\asyncinfo.h 108
Error 6 error C2872: …Run Code Online (Sandbox Code Playgroud) 首先:我知道一个包含“建议”的问题标题会引起反对票和“非建设性”标志,但如果您先阅读本文并考虑到我在以下方面面临具体问题,我会很高兴可访问的学习材料/文档。
ATM 我正在尝试将我现有的应用程序从 Linux 扩展到 Windows。结构基本上由包含多个静态本机 C++ 库的后端核心组成,我从前端项目(带有其他语言的 C/C++ GTK)中调用这些库。恕我直言,通过使用 core-C++ 库并将它们插入到不同平台特定的前端,将此类项目扩展到其他平台应该是一个非常普遍的计划。现在,在这种情况下,这将是一个 UWP 项目。
让我感到困惑的是微软与 C# 互操作策略的看似不一致的、目前正在转换的景观,特别是 C++/CX 和 C++/WinRT。我正在努力解决的中心问题是:在 UWP 应用程序中实现本机 C++ 库(也将它们作为项目嵌入到 Visual Studio 中以在 Windows 上提供本机构建体验和依赖项管理)的最佳方法是什么?C++/WinRT 似乎非常关注 WinRT 消耗(这是有道理的,因为它应该是这样的!)。C++/CX 似乎已被正式放弃和弃用,当您在 VS 中选择 Visual C++ 库项目时,它会自动引用 VC++ 库,这些库不是本机的,我担心某种中间层会妨碍您。
对于这种情况,必须有某种工业最佳实践,不是吗?
我目前正在开发一个需要一些文本资源的城域应用程序.构建过程的一部分是将所有这些资源复制到应用程序安装目录中的文件夹中.我想做的是收集这些资源文件的列表,并相应地处理每个文件.不幸的是,我这样做的尝试并不成功.
由于我正在为WinRT构建,我无法使用非常有用的"FindFirstFile"和"FindNextFile"函数.我一直在尝试使用WinRT异步文件IO操作完成工作.
auto getResourceFolder = installedLocation->GetFolderFromPathAsync( folderPath );
getResourceFolder->Completed = ref new Windows::Foundation::AsyncOperationCompletedHandler< Windows::Storage::StorageFolder^ >(
[this]( Windows::Foundation::IAsyncOperation< Windows::Storage::StorageFolder^ >^ operation ) {
if( operation->Status == Windows::Foundation::AsyncStatus::Completed ) {
auto resourceFolder = operation->GetResults();
auto getResourceFiles = resourceFolder->GetFilesAsync();
getResourceFiles->Completed = ref new Windows::Foundation::AsyncOperationCompletedHandler< IVectorView< Windows::Storage::IStorageFile^ >^ >(
[this]( Windows::Foundation::IAsyncOperation< IVectorView< Windows::Storage::IStorageFile^ >^ >^ operation ) {
if( operation->Status == Windows::Foundation::AsyncStatus::Completed ) {
auto resourceFiles = operation->GetResults();
for( unsigned int i = 0; i < resourceFiles->Size; ++i ) {
// Process File
} …Run Code Online (Sandbox Code Playgroud) visual-c++ microsoft-metro windows-runtime c++-cx visual-c++-2012
WPF/VC++(C++/cx) - Visual Studio 2013
所以我有一个ListBox,其中填充了我创建的UserControl.每次页面更改时数据都会丢失,这是不幸的.因此,我可以选择在每次加载页面时将数据加载到ListBox中,或者在页面之间传递数据.他们每个人都有自己的优势和劣势,但有一种做法更受欢迎吗?
我想要考虑的事情是ListBox中有多少UserControl,这可能是一个很大的数量(大到10000+),以及数据的存储方式.现在我将数据存储在AVLTree中,主要用于组织,因此不需要进行排序.通常只有10页,其中6页通常被导航到(其中4页是很少使用或仅使用过一次的菜单页面),因此数据不必经常在页面之间传递.每个数据节点的大小只有大约1mb,所以不是很大,但是大到足以在你开始超过10000个条目时产生差异(这可能被认为是一种罕见的情况).
我来自游戏编程,因此速度和效率是首要目标.
是的,这是一个主观问题,但是专业人士或一般编程社区可能有一个首选方法.
我有一个带有以下代码的头文件:
Microsoft::WRL:ComPtr<ID3D11Device2> m_device;
Run Code Online (Sandbox Code Playgroud)
在类定义中。Visual Studio 2013表示Microsoft不是名称空间,如果我将代码剪切并切下,然后将其放在另一个文件的另一个类中,则保持不变就可以了!
有任何想法吗?
菲利浦
编辑:突然之间(无需我进行任何更改)Intelissense现在接受Microsoft :: WRL :: ComPtry为有效,但是在我编译时它仍然给我错误,提示它不存在。
这是超级容易从去Platform::Guid^到Platform::String^与ToString()方法.有关详细信息,请参阅文档.
但是我们如何转换Platform::String^为Platform::Guid^?
编辑:
双方CLSIDFromString并IIDFromString就行了.请以接受的答案为例.还请#include <wrl\wrappers\corewrappers.h>.
我试图绑定(在XAML中)到C++/CX中的List,我似乎没有任何列表.它们都去了哪里?任何类型的列表都可以...甚至是字典,堆栈,或......某事!或有C++改变了那么多,因为我最后一次使用它?