我正在用C#制作一个Windows应用商店应用,我有一个普通的TextBlock,里面有一个链接.所有我想要做的就是当光标越过文本块时将光标变为手形,但与WPF应用程序不同,没有Cursor适当性.我知道是一个CoreCursor类Windows.UI.Core.我想以某种方式使用它吗?
我的Visual Studio似乎无法构建任何Metro Sample应用程序.因为我之前从未真正使用过这个IDE,所以我已经放弃了.
任何人都可以指示我已经构建的示例应用程序,最好是一些源代码以及它作为参考吗?
注意:
我有一个Windows 7和8的副本.但是我似乎无法在我的Visual Studio 2010 Ultimate副本中构建Microsoft的文件访问示例.我正在尝试在Win8的Metro模式下测试我的一个Win7应用程序(可以在给定Metro应用程序的用户会话期间调用该应用程序).
VS2012的默认C#"Metro风格"项目模板包括App.xaml.cs中的代码(在OnLaunched覆盖中),用于在暂停和终止后恢复应用程序状态.此代码仅当运行LaunchActivatedEventArgs.PreviousExecutionState是Terminated,即,"该应用程序正在暂停后终止".
如何强制我的应用程序暂停和终止,以便我可以在我的应用程序中测试此暂停/恢复功能?
我尝试过的东西不起作用:
PreviousExecutionState就是ClosedByUser.PreviousExecutionState就是NotRunning.即使任务管理器在我结束任务之前将应用程序显示为"已暂停",也是如此,因此显然它比"被暂停后终止"的描述更加细致.看起来,如果我从我的应用程序切换到StackOverflow窗口几分钟,我的应用程序最终会被终止,所以也许有一个基于时间的组件.但是如果我每次都要等待五到十分钟让我的应用程序终止,这是一个非常缓慢的测试周期.
鉴于这是开发人员必须测试的东西,你会认为开发人员有一个很好的,简单的方法来强制应用程序暂停和终止.是否有某种压力测试应用程序与Visual Studio一起提供足够的内存压力?Visual Studio中是否有一些菜单项会强制终止我的应用程序?我们该如何测试呢?
我正在尝试创建一个这样的表:

我怎样才能使用ListView或GridView做类似的事情?我找不到添加表格标题的正确方法..
我正在尝试使用Windows 8"Metro Styled Apps",MVVM Light,并希望创建一个共享目标 - 到目前为止一切顺利.但是如果我在OnShareTargetActivated方法中并且想要将项添加到ObservableCollection,我会在类类型和COM对象之间捕获InvalidCastException.
Das COM-Objekt des Typs"System.Collections.Specialized.NotifyCollectionChangedEventHandler"kann nicht in den Klassentyp"System.Collections.Specialized.NotifyCollectionChangedEventHandler"umgewandelt werden.Instanzen von Typen,die COM-Komponentenrepräsentieren,könnennichtin andere Typen umgewandelt werden,die keine COM-Komponentenrepräsentieren.Echn Umwandlung in Schnittstellen istjedochmöglich,sofern die zugrunde liegende COM-Komponente QueryInterface-AufrufefürdieIID derSchnittstelleunterstützt.
英文版:
无法将类型为"System.Collections.Specialized.NotifyCollectionChangedEventHandler"的COM对象强制转换为类类型"System.Collections.Specialized.NotifyCollectionChangedEventHandler".表示COM组件的类型实例不能转换为不代表COM组件的类型; 但是只要底层的COM组件支持对接口的IID的QueryInterface调用,它们就可以转换为接口.
现在我有点困惑,不知道如何正确处理这种行为.
MainViewModel main1 = new ViewModelLocator().Main;
MainViewModel main2 = new MainViewModel();
var conversation = new ConversationViewModel();
conversation.Messages.Add(new MessageViewModel { Image = img, Text = "Share" });
main1.Conversations.Add(conversation); // error InvalidCastException
main2.Conversations.Add(conversation); // no error
Run Code Online (Sandbox Code Playgroud)
img新创建的BitmapImage 在哪里
ViewModelLocator
public class ViewModelLocator
{ …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
public MainPage()
{
this.InitializeComponent();
this.ManipulationStarting += MainPage_ManipulationStarting;
this.ManipulationStarted += MainPage_ManipulationStarted;
this.ManipulationInertiaStarting += MainPage_ManipulationInertiaStarting;
this.ManipulationDelta += MainPage_ManipulationDelta;
this.ManipulationCompleted += MainPage_ManipulationCompleted;
}
void MainPage_ManipulationStarting(object sender, ManipulationStartingRoutedEventArgs e)
{
Debug.WriteLine("MainPage_ManipulationStarting");
}
void MainPage_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
Debug.WriteLine("MainPage_ManipulationStarted");
}
void MainPage_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingRoutedEventArgs e)
{
Debug.WriteLine("MainPage_ManipulationInertiaStarting");
}
void MainPage_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
Debug.WriteLine("MainPage_ManipulationDelta");
}
void MainPage_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
{
Debug.WriteLine("MainPage_ManipulationCompleted");
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何使用Manipulation事件.你能描述一下如何处理向上,向下,向左和向右滑动的手势吗?
我对这个看似简单的任务的明显复杂性感到震惊.我知道我必须使用这个StorageFile类,我已经找到了这个例子,但我只是想读一个单独的文件,我知道路径,并将它的数据作为文本读入字符串.
从我能够收集的内容,到阅读文件StorageFile,我必须经历一堆接口; IAsyncOperation<StorageFile>和IAsyncOperationCompletedHandler.
必须有更好(更简单)的方式.就像是:
using (StorageFile sf = StorageFile.OpenAsync("myFile.txt"))
{
string line = sf.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
显然这不起作用,但也许我错过了什么,或者有人可以向我解释如何以不同的方式阅读文件?
我正在使用C#类,它在我的Windows应用商店应用程序(C#)中运行得非常好.但是当我尝试在Windows运行时Compenent中使用它时,我收到以下错误:
Calculator.Calculate(System.DateTime)'具有'System.DateTime'类型的参数'dateTime'.'System.DateTime'不是有效的Windows运行时参数类型.
类中的示例对象:
public DateTime Calculate(DateTime dateTime)
{
int dayNumberOfDateTime = ExtractDayNumber(dateTime);
int sunRiseInMinutes = CalculateSunRiseInternal(tanSunPosition, differenceSunAndLocalTime);
return CreateDateTime(dateTime, sunRiseInMinutes);
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?问题是什么?
我搜索过网络和StackOverflow很多,但似乎无法找到我以下问题的明确答案.
语境:
我希望移植一组C++帮助程序库,以便与Windows Phone 8(WP8)平台一起使用.从历史上看,这些库是作为静态库(而不是DLL)构建的.
我已成功编写了特定于WP8的代码,因此使用WP8可用的API(使用WP API QuickStart doc作为参考点),库与ARM兼容并构建.由于必须用WinRT的ThreadPool替换经典的Win32 Thread调用,因此只有一个库(例如Lib1)需要使用WinRT扩展(/ ZW标志).
构建Lib1时,我收到以下警告:警告1警告LNK4264:将使用/ ZW编译的目标文件归档到静态库中; 请注意,在创作Windows运行时类型时,建议不要使用包含Windows运行时元数据的静态库进行链接.
- 搜索此警告,我发现这篇文章,指出:"如果您使用创建公共引用类,公共接口类或公共值类的静态库,链接器会引发此警告.如果静态,您可以安全地忽略警告库不会生成在库本身之外使用的Windows运行时组件.静态库中的公共组件将编译但不会在运行时激活.任何打算供其他组件或应用程序使用的Windows运行时组件必须在动态中实现-link library(DLL)."
在Lib1中,ClassA包含使用WinRT ThreadPool调用的函数.ClassA调用ClassA函数,它们只是将常规HANDLE和DWORD返回给ClassB.
代码示例:
// ClassA.cpp
HANDLE WINAPI ClassA::CreateThread(/* Params that are usually passed to Win32 CreateThread */)
{
// Do WinRTThreadPool stuff to create WorkItem
auto workItem = ref new Windows::System::Threading::WorkItemHandler([=](Windows::Foundation::IAsyncAction^)
// More code that eventually results in a Win32 Handle
return handle;
}
// ClassB.cpp
Handle handle = ClassA::CreateThread(/* Params that are usually passed to Win32 CreateThread */);
Run Code Online (Sandbox Code Playgroud)
ClassA的函数只能由ClassB从Lib1中调用,然后ClassB可以被链接Lib1的应用程序使用.
最后,对我的问题: …
c++ cross-platform static-libraries windows-runtime windows-phone-8
我正在开发一款同时针对Android的Windows Phone 8.1应用程序(Xamarin)
我一直在PCL上添加我的字符串资源(.resx)并在我的启动器项目中引用它们以在我的视图上使用它,这在WP 8.1 silverlight上运行正常,但在配置项目以释放并运行它时在WinRt上运行在设备上,由于某种原因,我总是得到一个MissingManifestResourceException.我已经尝试过解决这个问题的所有解决方案而没有任何成功.
请注意,在模拟器上一切正常,当解决方案配置器设置为Debug时,它也适用于设备和模拟器.这里唯一的组合是设备和发布.
应用源代码在Github上.
我能够创建一个简单的项目来复制这个问题,基本上它是一个WP 8.1应用程序和一个带有嵌入式资源的PCL项目,下载链接
有人有什么想法吗?
编辑:经过一些更多的测试,我尝试运行一个旧的Windows 8.1应用程序,我已经使用相同的本地化模型,并出现相同的问题所以它接缝是一个工具问题而不是配置问题,因为Windows 8.1应用程序是在市场上,一切都很顺利.
resx embedded-resource windows-phone windows-runtime windows-phone-8.1
windows-runtime ×10
windows-8 ×6
c# ×5
.net ×2
winrt-xaml ×2
xaml ×2
c++ ×1
cursor ×1
gridview ×1
listview ×1
mvvm-light ×1
resx ×1
wpf ×1