Good day to all!

The form has an ItemsControl. In the constructor of each item, there is a ComboBox in which the user selects the command he needs.

The question is how to determine the further construction of the item'a. For example, the user chose "Availability ..." and then a ComboBox should appear with a choice of a vehicle number and a ComboBox with a choice of type. Further, if the user selects "Get" in the type, nothing more should appear on the form, and if he selected "Set" in the type, then a field should appear to enter the value.

I would be glad if you shared information or links to the implementation of such structures. Interested in both setting up the interface and setting up the item class itself, which is created.

Code example:

<ItemsControl.ItemTemplate> <DataTemplate> <Border Width="350" Height="200" Background="DarkRed" BorderBrush="White" BorderThickness="2" CornerRadius="5" Margin="0,5,0,0"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto"></ColumnDefinition> <ColumnDefinition Width="auto"></ColumnDefinition> <ColumnDefinition Width="auto"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="auto"></RowDefinition> <RowDefinition Height="auto"></RowDefinition> </Grid.RowDefinitions> <ComboBox ItemsSource="{Binding Path=CommandNameList}" SelectedIndex="{Binding Path=CommandNameSelected}"></ComboBox> </Grid> </Border> </DataTemplate> </ItemsControl.ItemTemplate> 

Example: What it looks like now is a preliminary version without styles, and so on. Thanks for the help!

  • Is there a ComboBox in the constructor? What is it like? give the code - Andrew NOP
  • And add a picture with the image of what you want to receive, while nothing is clear - Andrey NOP
  • Yeah, only this is not a designer, but an element template - Andrey NOP
  • @ Andrei, yes, a template. Wrong. - UporotayaPanda
  • @ Andrey added a picture, I’m stuck on it. While I see only one option, create a universal template, and in the body of the class add fields for display (hidden, collapsedm, visible) and when choosing a specific option, enable or disable the necessary one. - UporotayaPanda

1 answer 1

 <ItemsControl.ItemTemplate> <DataTemplate> <Border Padding="10" BorderBrush="Black" BorderThickness="1"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="auto"/> <RowDefinition Height="auto"/> <RowDefinition Height="auto"/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <ComboBox Name="f_Root"> <ComboBox.Items> <System:String>Наличие...</System:String> <System:String>Получить</System:String> <System:String>Установить</System:String> </ComboBox.Items> </ComboBox> <ComboBox Name="f_TS" Grid.Row="1" Visibility="Hidden"/> <ComboBox Name="f_Type" Grid.Row="2" Visibility="Hidden"/> <TextBox Name="f_Value" Grid.Row="3" Visibility="Hidden"/> </Grid> </Border> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Path=SelectedItem, ElementName=f_Root}" Value="Наличие..."> <Setter Property="Visibility" Value="Visible" TargetName="f_TS"/> <Setter Property="Visibility" Value="Visible" TargetName="f_Type"/> </DataTrigger> <DataTrigger Binding="{Binding Path=SelectedItem, ElementName=f_Root}" Value="Установить"> <Setter Property="Visibility" Value="Visible" TargetName="f_Value"/> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> </ItemsControl.ItemTemplate> 

I think you can install the f_TS and f_Type elements =)

YES! I completely forgot!

Plug in control

 xmlns:System="clr-namespace:System;assembly=mscorlib" 
  • Thank! Good implementation! In future projects I will try to implement it myself! - UporotayaPanda