0

凍結できないことについて不平を言っているストーリーボードに問題があります。これについてグーグルにはたくさんのリンクがあります、しかし私はその情報を読んで私が望むものをどのように達成することができるかわかりません。(つまり、IsMouseOverプロパティの変更からカスタムコマンドを実行するだけです)。以下の情報で提供したリンクのようにリストビューを変更するためにデータテンプレートを使用しています。

私のリソース辞書:

<DataSourceProviders:ServiceLocatorProvider ServiceType="{x:Type Interfaces:IGestureBuilderModuleController}" x:Key="GestureController"/>

<Converters:IsGestureBeingBuiltConverter x:Key="IsGestureBeingBuildConverter" />

私のUIは次のようになります:

<ListView.ItemContainerStyle>
    <Style TargetType="{x:Type ListViewItem}">
        <Style.Triggers>
                <MultiDataTrigger>
                      <MultiDataTrigger.Conditions>
                          <Condition Binding="{Binding IsMouseOver}" Value="True" />
                          <Condition Binding="{Binding Path=CurrentGestureState, Converter={StaticResource IsGestureBeingBuildConverter}}" Value="True" />
                      </MultiDataTrigger.Conditions>

                      <!--TODO:Need to add a button to this control. Then use the buttons event to trigger command.-->

                      <MultiDataTrigger.ExitActions>

                            <BeginStoryboard>
                              <StoryBoard:CommandTimeline StoryBoard:CommandStoryboard.Command="{Binding Source={StaticResource ResourceKey=GestureController}, Path=AddToGestureCommand}" />
                            </BeginStoryboard>
                        </MultiDataTrigger.ExitActions>
                </MultiDataTrigger>
        </Style.Triggers>
    </Style>
</ListView.ItemContainerStyle>

私のコンバーターは次のようになります:

    [ValueConversion(typeof(GestureState), typeof(bool))]
public class IsGestureBeingBuiltConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return Equals(value, GestureState.BeingConstructed);
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

私のGestureState列挙型は次のようになります。

public enum GestureState
{
    Finished,
    BeingConstructed
}

私のジェスチャーコントローラー/コマンドは次のようになります。

public class GestureBuilderModuleController : ModuleController, IGestureBuilderModuleController
{
    public ICommand AddToGestureCommand
    {
        get { return new DelegateCommand<GestureBuilderViewModel>(viewModel => viewModel.AddToGesture = true); }
    }
}

私のビューモデルは次のようになります。

public GestureableItemViewModel ItemBeingAdded { get; set; }
public virtual bool AddToGesture
{
    get { return false; }
    set
    {
        if (ItemBeingAdded == null) return;
        if(CurrentGestureState != GestureState.BeingConstructed) return;

        SelectedItems.Add(ItemBeingAdded);
    }
}

私が得ている例外は次のとおりです。

InvalidOperation:ストーリーボードをフリーズできません。

私のUIは次のようになります。

http://socialbarrel.com/wp-content/uploads/2011/03/Android-Like-Gesture-Unlock-Screen-Being-Tested-By-Apple-Report.jpg?98c14d

現在の理解:

ストーリーボードは、フリーズされていないスレッド間ですばやくアクセスできるようにフリーズ可能である必要があることを読んで理解しています。

私の質問は、どのようにしてバインディングをフリーズ可能にするか、別のアプローチを使用して目的を達成できるかということです。私の主な問題は、ジェスチャをキャプチャするときにリストアイテムにマウスを合わせるときにカスタムコマンドまたはイベントを発生させたいということです。

4

1 に答える 1

1

ストーリーボードは必要ありません。Multidatatriggerで、OneWayToTarget DataBindingを使用して、ViewModelにプロパティを設定します。そのプロパティのセッターは、トリガー条件が満たされたときに呼び出されます。そのセッターでは、「this.AddToGesture=true」を呼び出すことができます。

于 2012-01-20T21:34:51.647 に答える