I have a ListBox
where it's DataTemplate
is as follows:
<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>
What I want to do is that when I choose the first item in modes
, companyName
's Width
would expand to 170, but nothing happens when I try this.
Can anyone tell me where is the error in my code?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.