小编obi*_*mme的帖子

使用数据模板将视图与视图模型关联时如何以动画方式从一个视图到另一个视图的转换

我将发布我目前拥有的源代码,然后解释我的问题。

这是我希望发生转换的窗口

<Window x:Class="MyApp.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MyApp" Height="600" Width="800">
<StackPanel>
    <Button Content="View1" Command="{Binding View1Command}"/>
    <Button COntent="View2" Command="{Binding View2Command}"/>
    <ContentControl Content="{Binding MyContent}"/>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

这是关联的视图模型

public class MainViewModel
{
    public RelayCommand View1Command{ get; private set;}
    public RelayCommand View2Command{ get; private set;}

    //INotifyPropertyChanged is implemented of course
    public ViewModelBase MyContent { get; set;}

    public MainViewModel()
    {
        View1Command = new RelayCommand(() => { MyContent = new ViewModel1();});
        View2Command = new RelayCommand(() => { MyContent = new ViewModel2();});
    }
}
Run Code Online (Sandbox Code Playgroud)

在 app.xaml 中,我使用数据模板将 ViewModel1 与 …

wpf animation transition mvvm mvvm-light

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

在select中使用ngPluralize

是否可以在使用ngOoptions配置的选择标记内部使用ngPluralize来复制下拉列表的选项?

我目前有以下控制器

function Ctrl ($scope) {
  $scope.ranges = [1, 2, 3, 4, 5];
  $scope.range = $scope.ranges[4];

  $scope.$watch('range', function(val) {
    console.log('change' + val);
  });
};
Run Code Online (Sandbox Code Playgroud)

和以下标记

<div ng-controller="LiveViewerCtrl">
  <select ng-model="range" 
          ng-options="range for range in ranges" 
          ng-pluralize 
          count="range" 
          when="{'1': '1 Minute', 'other': '{} Minutes'}">
  </select>
</div>  
Run Code Online (Sandbox Code Playgroud)

我也尝试使用ng-repeat自己创建选项,并且工作正常.不幸的是,下拉列表有一个空的默认值,虽然我在控制器中指定了默认值,但未预先选择.如果我使用ngOptions方法预选工作,但值不是复数.

javascript angularjs

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

标签 统计

angularjs ×1

animation ×1

javascript ×1

mvvm ×1

mvvm-light ×1

transition ×1

wpf ×1