Я пытаюсь привязать a к команде, определенной в DataContext
из xaml
в DataGridColumn
, однако я не могу использовать RelativeSource
, поскольку столбцы не являются частью иерархии, поэтому мое текущее решениепоэтому определите команду в ResourceDictionary
и сделайте ссылку на нее.
Однако моя проблема в том, что я не могу найти, как определить ICommand
в ResourceDictionary
, как я могу это сделать?Или любые другие способы доступа к моей команде в DataContext
из DataGridColumn
?
xmlns:input="clr-namespace:System.Windows.Input;assembly=System"
...
<UserControl.Resources>
<ResourceDictionary>
<input:ICommand x:Key="propertyChangedEvent">
"{Binding PropertyChangedEvent}"
</input:ICommand>
</ResourceDictionary>
</UserControl.Resources>
...
<DataGridTemplateColumn Header="Notes" MinWidth="350" Width="*" IsReadOnly="False">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Margin="1">
<TextBox Text="{Binding Notes, UpdateSourceTrigger=LostFocus}" BorderThickness="0" AcceptsReturn="True" TextWrapping="Wrap" >
<i:Interaction.Triggers >
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction Command="{StaticResource propertyChangedEvent}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>