如何单击按钮,然后将txtNoOfVehicles
的Value
设置为NULL
或""
?
<dxg:GridControl ItemsSource="{Binding ShiftEntries}">
<dxg:GridControl.Columns>
<dxg:GridColumn Header="No. of Vehicles">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<dxe:TextEdit x:Name="txtNoOfVehicles" Text="{Binding RowData.Row.NoOfVehicles}" Mask="d{1,4}" MaskType="RegEx" NullText="Infinity" NullValue="{x:Null}" AllowNullInput="True" ShowError="False" />
<Button Content="Infinity" Margin="3" />
</StackPanel>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
</dxg:GridControl.Columns>
</dxg:GridControl>
我研究了样式/数据/事件触发器,但我看到的所有示例都针对应用了触发器的同一控件。我希望单击按钮时的触发器,并且目标是TextEdit
的Text
属性。
我尝试过:
<Button Content="Infinity" Margin="3">
<Button.Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="txtNoOfVehicles" Property="dxe:TextEdit.Text" Value="{x:Null}" />
</Trigger>
</Style.Triggers>
</Button.Style>
</Button>
要回答您的问题,您可以执行类似的操作
<StackPanel>
<TextBlock Name="Block" Text="Test" />
<Button Name="btn">
<Button.Triggers>
<EventTrigger SourceName="btn" RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Block"
Storyboard.TargetProperty="Text"
>
<DiscreteObjectKeyFrame Value=""></DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Button.Triggers>
</Button>
</StackPanel>