我有一个ListBox
,DataTemplate
如下:
<DataTemplate>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="180"/>
<ColumnDefinition />
<ColumnDefinition Width="180"/>
<ColumnDefinition Width="180" />
</Grid.ColumnDefinitions>
<ComboBox Name="modes" ItemsSource="{Binding Modes}" Margin="10,3"/>
<ComboBox Name="companyName" ItemsSource="{Binding Companies}" Grid.Column="1" IsEditable="True" Width="0" Margin="10,3">
<ComboBox.Style>
<Style TargetType="ComboBox">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=SelectedIndex, ElementName=modes}" Value="0" >
<DataTrigger.EnterActions>
<BeginStoryboard >
<Storyboard >
<DoubleAnimation Storyboard.TargetProperty="Width"
From="0" To="170" Duration="200"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
<TextBox Grid.Column="2" Margin="3"/>
<TextBox Grid.Column="3" Margin="3"/>
<ComboBox ItemsSource="{Binding Providers}" Grid.Column="4" IsEditable="True" Margin="10,3"/>
</Grid>
</DataTemplate>
我想要做的是,当我选择modes
中的第一项时,companyName
的{{1}}会扩展为170,但尝试此操作时没有任何反应。
有谁能告诉我代码中的错误在哪里?