我是C#和MVVM的新手,我花了一整天的时间来尝试获取ComboBox我的ViewModel 的值SelectionChanged.我已设法使用其中一个CallMethodAction或InvokeCommandAction与资源一起计算出来:
System.Windows.Interactivity.dllMicrosoft.Expression.Interactions.dll我的问题是这两个方法都返回ComboBox它更改之前的值.任何人都可以解释如何在变更后获得价值吗?
我花了几个小时搜索SO和Google的解决方案,所以我想知道其他人是否也是如此.任何建议将被认真考虑!
我的代码如下:
MainWindow.xaml
<Window x:Class="SelectionChange.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:si="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
xmlns:vm="clr-namespace:SelectionChange"
Title="MainWindow" Width="300" Height="300">
<Window.DataContext>
<vm:ViewModel />
</Window.DataContext>
<Grid>
<ComboBox Name="SelectBox" VerticalAlignment="Top" SelectedIndex="0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<si:CallMethodAction MethodName="SelectionChanged" TargetObject="{Binding}" />
<!--<i:InvokeCommandAction Command="{Binding SelectionChangedCommand}" CommandParameter="{Binding ElementName=SelectBox, Path=Text}" />-->
</i:EventTrigger>
</i:Interaction.Triggers>
<ComboBoxItem Content="Item 1" />
<ComboBoxItem Content="Item 2" />
<ComboBoxItem Content="Item 3" />
</ComboBox>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
ViewModel.cs
namespace SelectionChange
{
using System;
using System.Windows;
using System.Windows.Controls; …Run Code Online (Sandbox Code Playgroud) 我正在使用Capistrano部署我的Rails应用程序,除非我将ssh放入服务器并RAILS_ENV=development bundle exec rake assets:precompile手动运行,否则似乎不会对资产进行编译。
我已经尝试按照capistrano / rails github页面上的说明进行操作,但是不确定是否错过了一些内容。
运行cap production deploy成功完成。但是我不知道如何检查assets:precompile任务是否实际运行。运行cap production deploy:assets:precompile也成功完成,但是服务器上没有明显变化。
版本号
Server version: Apache/2.4.7 (Ubuntu)
Phusion Passenger 5.0.22
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
Rails 4.2.5
capistrano (3.1.0)
capistrano-bundler (1.1.4)
capistrano-rails (1.1.6)
capistrano-rbenv (2.0.4)
Run Code Online (Sandbox Code Playgroud)
Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/rails/assets'
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
Run Code Online (Sandbox Code Playgroud)
config / deploy.rb
set :application, "website"
set :repo_url, "git@bitbucket.org:company/website.git"
set :deploy_to, "/var/www/#{fetch(:application)}"
set :user, "webmaster"
set :rbenv_path, …Run Code Online (Sandbox Code Playgroud) capistrano ruby-on-rails asset-pipeline ruby-on-rails-4 capistrano3