19
複数のビデオが表示されていますが、MainviewModelのビデオコレクションにバインドされています。 Mainviewmodelにenterコマンドをバインドしようとするまで、すべてうまく動作します。私はこれの構文を知らない。それが現れると、バインディングはMainviewmodelではなくVideoに設定されます。データテンプレート内からviewmodelへのバインド
にErrorMessage:
'StartVideoCommand' property not found on 'object' ''Video'
XAML: `コマンド=" {バインディングRelativeSource = {RelativeSource AncestorType = {X:
<Window.Resources>
<local:MainViewModel x:Key="MainViewModel"/>
</Window.Resources>
<Grid DataContext="{StaticResource MainViewModel}">
<ListBox ItemsSource="{Binding Videos}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.InputBindings>
!!! <KeyBinding Key="Enter" Command="{Binding StartVideo}" /> !Bound to Video not to Mainviewmodel grrr
</Grid.InputBindings>
... layout stuff
<TextBlock Text="{Binding Title}" Grid.Column="0" Grid.Row="0" Foreground="White"/>
<TextBlock Text="{Binding Date}" Grid.Column="0" Grid.Row="1" Foreground="White" HorizontalAlignment="Left"/>
<TextBlock Text="{Binding Length}" Grid.Column="1" Grid.Row="1" Foreground="White" HorizontalAlignment="Right"/>
... closing tags
私はので、私がしたコマンドにバインドする必要がありましたタイプUserControl}}、Path = DataContext.COMMAND_I_WANT_TO_BIND_TO} "' –