从 WPF 中的 RadGridView 中的 RadDatePicker 调用 LostFocus 事件
Invoking LostFocus event from RadDatePicker inside a RadGridView in WPF
我有一个 RadGridView
,里面有一个 RadDatePicker
我想在那个日期的任何更改上触发 command
。
我正在努力通过
实现这一目标
<telerik:GridViewColumn Header="Date of Travel" >
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=FlightDetails.FltDate, StringFormat=dd-MMM-yyyy}">
</TextBlock>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
<telerik:GridViewColumn.CellEditTemplate>
<DataTemplate>
<telerikControls:RadDatePicker SelectedDate="{Binding Path=FlightDetails.FltDate,UpdateSourceTrigger=LostFocus,Mode=TwoWay, StringFormat=dd-MMM-yyyy}" DisplayFormat="Short" Culture="en-AU">
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<i:InvokeCommandAction Command="{Binding DataContext.DateOfFlightCommand, RelativeSource={RelativeSource AncestorType={x:Type baseview:QRUserControl}}}"
CommandParameter="{Binding}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</telerikControls:RadDatePicker>
</DataTemplate>
</telerik:GridViewColumn.CellEditTemplate>
</telerik:GridViewColumn>
没有触发。
您的绑定可能无效。如果 DateOfFlightCommand
属性 在父 window 的视图模型中定义,则应将 Window
指定为 AncestorType
:
<i:InvokeCommandAction Command="{Binding DataContext.DateOfFlightCommand,
RelativeSource={RelativeSource AncestorType={x:Type Window}}}" CommandParameter="{Binding}" />
但是,当然没有人会知道您的 类 和属性之间的关系,除非您包含所有相关的代码片段。在你问另一个问题之前你应该阅读这个:https://whosebug.com/help/mcve
我有一个 RadGridView
,里面有一个 RadDatePicker
我想在那个日期的任何更改上触发 command
。
我正在努力通过
实现这一目标<telerik:GridViewColumn Header="Date of Travel" >
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=FlightDetails.FltDate, StringFormat=dd-MMM-yyyy}">
</TextBlock>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
<telerik:GridViewColumn.CellEditTemplate>
<DataTemplate>
<telerikControls:RadDatePicker SelectedDate="{Binding Path=FlightDetails.FltDate,UpdateSourceTrigger=LostFocus,Mode=TwoWay, StringFormat=dd-MMM-yyyy}" DisplayFormat="Short" Culture="en-AU">
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<i:InvokeCommandAction Command="{Binding DataContext.DateOfFlightCommand, RelativeSource={RelativeSource AncestorType={x:Type baseview:QRUserControl}}}"
CommandParameter="{Binding}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</telerikControls:RadDatePicker>
</DataTemplate>
</telerik:GridViewColumn.CellEditTemplate>
</telerik:GridViewColumn>
没有触发。
您的绑定可能无效。如果 DateOfFlightCommand
属性 在父 window 的视图模型中定义,则应将 Window
指定为 AncestorType
:
<i:InvokeCommandAction Command="{Binding DataContext.DateOfFlightCommand,
RelativeSource={RelativeSource AncestorType={x:Type Window}}}" CommandParameter="{Binding}" />
但是,当然没有人会知道您的 类 和属性之间的关系,除非您包含所有相关的代码片段。在你问另一个问题之前你应该阅读这个:https://whosebug.com/help/mcve