나는 비슷한 질문을 몇 번 보았으므로 신속하게 기각하지 마십시오. 시나리오가 여기에서 다르게 보입니다. 왜 잘못 될지 알 수 없습니다. 내 DataGrid
키와 마우스 클릭 몇 가지 바인딩이 있습니다BindingExpression 경로 오류 : ''컬렉션의 현재 항목 '에 속성이 없습니다. ... BindingExpression : Path = /;
<DataGrid x:Name="gridStudents" ItemsSource="{Binding Source={StaticResource cvsStudentList}}"
Margin="2"
Height="250"
SelectedItem="{Binding SelectedStudentItem, UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False" IsReadOnly="True" IsSynchronizedWithCurrentItem="True" SelectionChanged="gridStudents_SelectionChanged">
<DataGrid.InputBindings>
<MouseBinding
MouseAction="LeftDoubleClick"
Command="{Binding EditStudentButtonClickCommand}"
CommandParameter="{Binding /}" />
<KeyBinding Key="Delete" Command="{Binding DeleteStudentButtonClickCommand}" />
</DataGrid.InputBindings>
는 I에 유래 및 기존 사용자 기여에 대한 방법론 감사를 발견했다. 매우 감사.
이 문제는 MouseBinding CommandParameter
과 관련이 있습니다. 프로그램은 경고없이 잘 실행됩니다. DataGrid
에있는 행을 두 번 클릭하면 설계된대로 동작합니다.
하지만 비주얼 스튜디오 2015에서 출력 창을 확인하면 나는이 발언 볼 수 있습니다
System.Windows.Data Error: 40 : BindingExpression path error: '' property not found on 'current item of collection' ''OCLMEditorModelView' (HashCode=43686667)'. BindingExpression:Path=/; DataItem='OCLMEditorModelView' (HashCode=43686667); target element is 'MouseBinding' (HashCode=49684624); target property is 'CommandParameter' (type 'Object')
가 왜 이런 말된다? ItemSource
이 CollectionViewSource
개체이기 때문에 /
을 사용했으며 현재 선택한 항목을 호출하는 것으로 알고 있습니다. 하지만 실제로이 행을 두 번 클릭하기 전까지는이 명령이 실행되지 않습니다.
내 출력 창에 어떻게 나타나는지 궁금합니다.
나는 대답 당 나는이 예외가로 바인딩을 변경하려고하는 경우 :
업데이트 : 지금
<MouseBinding
MouseAction="LeftDoubleClick"
Command="{Binding EditStudentButtonClickCommand}"
CommandParameter="{Binding /, Source={RelativeSource Self}}" />
그러나 다음은
현재 XAML입니다 출력 창에 다음과 같이 표시됩니다.System.Windows.Data Error: 40 : BindingExpression path error: '' property not found on 'current item of collection' ''RelativeSource' (HashCode=472027)'. BindingExpression:Path=/; DataItem='RelativeSource' (HashCode=472027); target element is 'MouseBinding' (HashCode=36454430); target property is 'CommandParameter' (type 'Object')
작동하는 것처럼 보입니다. 행을 두 번 클릭하면 원하는대로 작동합니다. 그래서이 출력 경고를 멈출 수 있습니까?
업데이트 :
그래서이 현재 XAML입니다 :
내가 할 tryign 나는 무엇<DataGrid x:Name="gridStudents" ItemsSource="{Binding StudentsView}"
Margin="2"
Height="250"
SelectedItem="{Binding SelectedStudentItem, UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False" IsReadOnly="True" IsSynchronizedWithCurrentItem="True" SelectionChanged="gridStudents_SelectionChanged">
<DataGrid.InputBindings>
<MouseBinding
MouseAction="LeftDoubleClick"
Command="{Binding EditStudentButtonClickCommand}"
CommandParameter="{Binding /, Source={RelativeSource Self}}" />
<KeyBinding Key="Delete" Command="{Binding DeleteStudentButtonClickCommand}" />
</DataGrid.InputBindings>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
</DataGrid.CellStyle>
가 변경되지 않은이 - 사용자의 (a CVS에 boudn되는) 데이터 그리드 행을 두 번 클릭 할 때 해당 행을 기반으로 명령을 호출합니다. 입력의 맥락에서
'(T) 매개 변수'만 쓰면 'Convert.ChangeType'을 사용하지 마십시오. –
'RelativeSource' * 확장자 *는'RelativeSource' * 속성에만 유효합니다,'Source'가 아닙니다. 또한'RelativeSource Self'는 반드시 여러분의 컬렉션이 아닌'MouseBinding'을 참조 할 것입니다. –
@ H.B. 업데이트 된 질문 (아래). –