Casting in MVVM Light CommandParameterValue
-
23-09-2019 - |
문제
here is my Problem, I want to pass the integer 1 when this canvas is pressed. Every time I click the canvas, I get a An unhandled exception of type 'System.InvalidCastException' occurred in GalaSoft.MvvmLight.dll. Now I could make my life easier and just do the RelayCommand to accept a String instead of int but for the sake of learning. How would i go about doing it this way,
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<cmd:EventToCommand Command="{Binding ButtonPress}"
CommandParameterValue="1"
</i:EventTrigger>
</i:Interaction.Triggers>
해결책
이 항목과 관련된 문제입니다 검색에서 콘텐츠 유형을 무시하십시오
또는 이것이 도움이 될 수 있습니다 - isDocument : 1 http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2009/08/26/excluding-folders-from-search-results.aspx
다른 팁
You can pass datatypes other than string to the command using the following syntax:
<i:EventTrigger EventName="MouseLeftButtonDown">
<cmd:EventToCommand Command="{Binding ButtonPress}">
<cmd:EventToCommand.CommandParameterValue>
<s:Int32>1</s:Int32>
</cmd:EventToCommand.CommandParameterValue>
</cmd:EventToCommand>
</i:EventTrigger>
Add the flowing namespace declaration for s:
xmlns:s="clr-namespace:System;assembly=mscorlib"
제휴하지 않습니다 StackOverflow