小编Der*_*tie的帖子

处理不同MvvmCross(v3)平台的GoBack的最佳方法是什么

在MvvmCross v3中,我使用ShowViewModel导航到不同的页面.在转换为Mvx之前,我将使用该NavigationService.GoBack()方法返回上一页.优点是不重新创建页面.

由于该GoBack方法是特定于WP,WInRT,Silverlight的平台,处理返回上一页的最佳方法是什么,因此视图模型保持平台无关?

一种解决方案可能是使用ShowViewModel传递视图可以看到的一些数据,然后在WP/WinRT的情况下,RemoveBackEntry从视图调用.但是对于Mvx,可能有更好的方法.

c# mvvmcross

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

FlipView SelectionChanged事件仅在触摸操作完成时发生

来自文档:

注意当用户使用触摸交互翻转FlipView内容时,只有在触摸操作完成时才会发生SelectionChanged事件.这意味着当用户快速翻阅内容时,并不总是为每个项目生成单个SelectionChanged事件,因为操作仍在进行中.

有没有办法配置FlipView控件SelectionChanged为每次翻转启动?这种行为使得实现分页很有趣,因为如果用户足够快地翻转,可以在添加更多项目之前翻转到列表的末尾.

xaml flipview windows-8.1 windows-phone-8.1

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

Resharper和Namespace别名限定符

我已经搜索了一下这个并尝试了一些东西,如果不把我想要的东西丢掉,就无法让它工作.

通常我让Resharper使用名称空间优化.在将DTO映射到域模型对象的服务实现中,为每个对象创建别名是一个很好的可视化.这样,当它很晚,你的睡眠被剥夺了看到Dtos.CustomerDomainModel.Customer帮助.

using DomainModel = MyProduct.Core.Domain.Model;
using Dtos = MyProduct.ServiceModel.Dtos;
Run Code Online (Sandbox Code Playgroud)

当我运行代码清理时,它将更改为:

using DomainModel = MyProduct.Core.Domain.Model;
using Customer = MyProduct.Core.Domain.Model.Customer;
Run Code Online (Sandbox Code Playgroud)

有没有人这样做或类似的东西,并保持R#打击它?

c# resharper resharper-6.0

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

v3中导航参数中的自定义类型

在v3中,如果我想将两个对象传递给另一个viewmodel:

public class Dog
{

}

public class Cat
{

}

var dog = new Dog();
var cat = new Cat();

ShowViewModel<SomeViewModel>(new {Dog = dog, Cat = cat });

public class SomeViewModel
{
  Init(Dog dog, Cat cat)
  {
  }
}
Run Code Online (Sandbox Code Playgroud)

据我所知,这是行不通的,因为类型不被识别,不能卡在字典中.如果我希望将这些序列化为json,传递给视图模型,并反序列化为Init参数,我会实现IExtraParser吗?如果这是正确的,我该如何将实现添加到ExtraParsers字典?

更新:

这似乎是这样做的:

var foo = Mvx.Resolve<IMvxFillableStringToTypeParser>();
foo.ExtraParsers.Add(new MyParser());
Run Code Online (Sandbox Code Playgroud)

mvvmcross

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

Silverlight ApplicationLifetimeObjects与Application ResourceDictionary

在Silverlight应用程序中,将对象添加到ApplicationLifetimeObjects与Application ResourceDictionary之间有什么区别?

silverlight

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

Caliburn Micro:主shell VM中的"children"VM

我从Caliburn.micro开始,我有点困惑.假设我有一个带有2个窗格的UI,例如(这是一个假的样本)CustomersView和CustomerView,以及2个相应的VM,CustomersViewModel和CustomerViewModel.

现在,假设我想将两个窗格都包含在主shell中,它应该能够像数据成员一样访问所有VM:例如

public class MainViewModel
{
  private CustomerViewModel _vmCustomer;
  private CustomersViewModel _vmCustomers;
  ...
}
Run Code Online (Sandbox Code Playgroud)

由于视图模型是由CM创建的,我如何将主shell连接到它们的每个实例?或者这是一种错误的方法?我不需要在规范意义上的指挥,因为我没有激活或停用MDI中的一组窗格:我有一个带有一些窗格的SDI UI,每个窗格都由其VM支持,还有一个主shell应该是操纵他们.类似场景中的正确方法是什么?

caliburn.micro

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

从ALAssset检索时CGImage方向问题

我刚开始学习iPhone应用程序开发.我正在尝试使用ALAsset类从我的相册中检索照片,并将照片上传到我的服务器.但是,在纵向模式下拍摄的照片向左旋转90度,同时正确上传风景照片.我究竟做错了什么?在NSLog中,我确实看到方向为3,但照片仍然向左旋转90度.任何帮助将不胜感激.

这是我的代码片段:

ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
   NSString *documentsDirectory = [paths objectAtIndex:0];

   imagePath = [[documentsDirectory stringByAppendingPathComponent:@"latest_photo.jpg"] copy];
   NSLog(@"imagePath = %@", imagePath);

   ALAssetRepresentation *rep = [myasset defaultRepresentation];
   ALAssetOrientation orientation = [rep orientation];
   NSLog(@"Orientation = %d", orientation);

   CGImageRef iref = [rep fullResolutionImage];

   if (iref) {
      UIImage *largeimage = [UIImage imageWithCGImage:iref scale:1.0 orientation:orientation];
      NSData *webData = UIImageJPEGRepresentation(largeimage,0.5);

      [webData writeToFile:imagePath atomically:YES];

      // Upload the image
Run Code Online (Sandbox Code Playgroud)

iphone xcode uiimage cgimage alasset

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

将同步或异步方法作为任务使用

我正在寻找codeplex上的下载管理器类型项目并且遇到了这个问题:http: //nthdownload.codeplex.com/

浏览我运行的代码AddDownloads,如下所示:

AddDownloads启动_downloadQueue.AddDownloads任务并继续执行viewMaintenanceTask任务.如果你看看在这两个任务和下游发生的方法和事情,似乎一切都是同步的.

另外阅读这篇博客文章,同步任务与任务我试图了解包装同步方法的优势,如果有的话TaskCompletionSource.是因为它为API使用者提供了在单独的线程上启动任务的选项,或者仅仅是因为您希望将该方法用作a Task.同步方法是否TaskCompletionSource受益于并行处理?

private Task<QueueOperation> AddDownloads(IEnumerable<IDownload> downloads, out Task<QueueOperation> startTask)
{
    var addTask = _downloadQueue.AddDownloads(downloads, out startTask);

    // Maintain views
    var viewMaintenanceTask = addTask.ContinueWith(t =>
    {
        if (t.Exception == null)
        {
            var addedDownloads = t.Result.DownloadErrors.Where(k => k.Value == null).Select(k => k.Key).ToList();
            var activeDownloads = ActiveDownloads.ToList();
            AddToActiveDownloads(addedDownloads.Except(activeDownloads).ToList(), false);
        }
        else
        {
            // Rethrow exception, this ensures it'll bubble up to any further ContinueWith chained …
Run Code Online (Sandbox Code Playgroud)

c# async-await

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