-
March 5th, 2021, 10:31 PM
#1
Questions about ComboBoxes (collapse and "autoselect")
Hi,
I've a combobox(CadastreCombo) and a stackPanel containing a label and another combobox (DesSecCombo).
Try 1 : I try to make the stackPanel visible depending if the SelectedItem of the first combobox(CadastreCombo) is null or not.
I tryed that, but it's not working and I don't understand why it's not working
Code:
<StackPanel Name="DesSecStackPanel"
Orientation="Horizontal"
Margin="30,10,0,10" >
<StackPanel.Style>
<Style TargetType="StackPanel">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=CadastreCombo, Path=IsSelected}" Value="True">
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<Label Content="Désignation secondaire : "/>
<ComboBox Name="DesSecCombo"
MinWidth="180"
ItemsSource="{Binding Path=SelectedCadastre.DesignationsSecondaires}"
DisplayMemberPath="Description"
SelectedValuePath="Code"
SelectedItem="{Binding Path=SelectedDesSec}" />
</StackPanel>
Try 2 : Because the second combobox depends of the selectedItem of the first one, time to time the second combobox containes only one item. In this case (if the comboBox.itemsSource count>0), automatically select the item.
I'm able to solve both problems via the "backstage", but I try to learn and understanding xaml. And it's still complicated for me.
Thanks for help, but especially for explanations.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|