Dropdown Combobox with a Button MVVM RRS feed

  • Question

  • I can easily trigger a combobox to dropdown it's list if I use the code behind file.  That being said I've also got commands working so when I press a button, I fire a command function in my ModelView.  That being said, my ModelView has no access to the controls in the view (as it should be), so therefor I've got to trigger this in the view XAML code. So the closest thing I've found is this:

                 xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" x:Class="ConfigurationView" 
                 mc:Ignorable="d" Height="409" Width="448">
                <RowDefinition Height="336"/>
                <RowDefinition Height="*"/>
            <StackPanel  Background="#FFF4F3F3" Grid.Row="0">
                <Label x:Name="ConfigurationLabel" Content="CONFIGURATION" Margin="24,30,216,0" Foreground="#FFA19D9D" FontSize="30" FontFamily="Microsoft Yi Baiti" Height="36" VerticalAlignment="Top"/>
                <Label x:Name="TicketsLabel" Content="BOARD TO ACCEPT PRTG TICKETS" Margin="24,10,191,0" Foreground="#FFA19D9D" FontSize="15" FontFamily="Microsoft Yi Baiti" Height="24" VerticalAlignment="Top"/>
                <StackPanel  Background="#FFF4F3F3" Orientation="Horizontal" Margin="30,0" >
                    <ComboBox Name="BoardsComboBox" 
                              DataContext="{Binding Path=CurrentConfiguration, Mode=TwoWay}" 
                              ItemsSource="{Binding Path=Boards}" Height="30"  Width="357" VerticalAlignment="Top" ScrollViewer.CanContentScroll="True" >
                            <Style TargetType="ComboBox">
                                    <DataTrigger Binding="{Binding ElementName=DropdownButton, Path=Click}" Value="True">
                                        <Setter Property="IsDropDownOpen" Value="True"/>
                    <Button Name="DropdownButton" Command="{Binding Path=DropDownCommand}" Content="V" Width="30" Height="30" Background="#FF0A980A" Foreground="#FFFCFFFC" />
            <Border Grid.Row="1" Background="#FFDBDADA">
                <Button Content="SAVE" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="74" Height="35" Background="#FF0A980A" Foreground="White" FontSize="17" FontFamily="Microsoft Yi Baiti" Margin="0,0,30,20" FontWeight="Bold"/>

    As you can see I'm trying to style the combobox with a DataTrigger that fires when the button is clicked.  Can anyone see anything drastically wrong with this.  Am I on the right path? 

    I know it's a data trigger and not an event trigger but event triggers cause errors in those spots. I'm lost in the woods of WPF and MVVM.

    Taylor Deiaco Junior Developer Denver, CO

    Friday, July 22, 2016 7:30 PM