我有一个组合框。每个项目由一个标题和一个描述组成。
我想在第二项中使用一个文本框。这很好用。;)
现在我想问(因为带有文本框的项目高于所有其他项目),是否有可能如果选择的项目(带有文本框)不显示文本框,只显示内容作为字符串?
<ComboBox Height="35" Margin="0 2 0 2" SelectedIndex="0">
<ComboBoxItem>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="/WpfApplication14;component/Resources/Icon1.ico" Height="22" Width="22" Grid.Column="0" HorizontalAlignment="Left" />
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="16" MinHeight="16" MaxHeight="16" />
<RowDefinition Height="16" MinHeight="16" MaxHeight="16" />
</Grid.RowDefinitions>
<TextBlock Text="Item Titel 1" Grid.Row="0" FontWeight="Bold" />
<TextBlock Text="Item Beschreibung 1" Grid.Row="1" FontStyle="Italic">
<TextBlock.TextEffects><TextEffect Foreground="#FF555454" /></TextBlock.TextEffects>
</TextBlock>
</Grid>
</Grid>
</ComboBoxItem>
<ComboBoxItem>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="/WpfApplication14;component/Resources/Icon2.ico" Height="22" Width="22" Grid.Column="0" HorizontalAlignment="Left" />
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="16" MinHeight="16" MaxHeight="16" />
<RowDefinition Height="24" MinHeight="24" MaxHeight="24" />
</Grid.RowDefinitions>
<TextBlock Text="Item Titel 2" Grid.Row="0" FontWeight="Bold" />
<TextBox Grid.Row="1">
<TextBox.Text>c:\temp\test</TextBox.Text>
<TextBox.Style>
<Style>
<Setter Property="TextBox.Height" Value="20"/>
</Style>
</TextBox.Style>
</TextBox>
</Grid>
</Grid>
</ComboBoxItem>
</ComboBox>