Problem

Command not firing in popup button

Posted 5 years ago by Avatar Billy Jacobs
I have the following XAML. I am binding a command to the click event of a popup button. It does bind correctly because I get no binding error and the CanExecute fires when the control is loaded.

Note: The Command on line 3 fires correctly but not the command on line 5. Everything else works perfectly.
            <DataTemplate x:Key="PhysicalFindingTemplate" >
                <StackPanel Orientation="Horizontal">
                    <CheckBox Name="_physicalFindingCheckbox" Command="{Binding Path=DataContext.AddDeletePhysicalFindingCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PhysicalExaminationControl}}}" CommandParameter="{Binding}" IsChecked="{Binding IsInUseForPatient, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  />
                    <TextBlock Text=" " />
                    <shared:PopupButton PopupContent="{Binding}" Command="{Binding Path=DataContext.AddPhysicalFindingCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PhysicalExaminationControl}}}" CommandParameter="{Binding}"  VerticalContentAlignment="Center" Margin="0,0,10,0" x:Name="popupButtonContentXAML" Background="White" IsRounded="True" Grid.Column="1" Grid.Row="1" DisplayMode="Merged" Content="{Binding PhysicalFinding.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                        <shared:PopupButton.PopupContentTemplate>
                            <DataTemplate>
                                <shared:ResizableContentControl MinHeight="50" MinWidth="300" Padding="1">
                                    <StackPanel Name="_modifiersStackPanel" Background="{DynamicResource VerticalBackgroundBrush}" RenderTransformOrigin="0.5,0.5">                                                                                <Label Margin="5,0,5,0" Foreground="White" FontWeight="Bold"  HorizontalAlignment="Left" Height="28" Name="_preTextLabel" Width="120">Pre Text</Label>
                                        <TextBox Margin="5,0,5,5" Name="_preText" Text="{Binding Path=PreText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />

                                        <Label Margin="5,0,5,0" Foreground="White" FontWeight="Bold" HorizontalAlignment="Left" Height="28" Name="_postTextLabel" Width="120">Post Text</Label>
                                        <TextBox Margin="5,0,5,5" Name="_postText" Text="{Binding Path=PostText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                        <ItemsControl ItemsSource="{Binding ModifierTypes}">
                                            <ItemsControl.Resources>
                                                <DataTemplate x:Key="SelectedItemTemplate">
                                                    <RadioButton IsThreeState="True" Command="{Binding Path=DataContext.AddDeletePhysicalFindingModifierCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:PhysicalExaminationControl}}}" CommandParameter="{Binding}" Content="{Binding Path=Modifier.Name}" IsChecked="{Binding Path=IsInUseForPatient}">
                                                    </RadioButton>
                                                </DataTemplate>
                                            </ItemsControl.Resources>
                                            <ItemsControl.ItemTemplate>
                                                <DataTemplate>
                                                    <StackPanel>
                                                        <Label Margin="5" FontWeight="Bold" Foreground="White" Content="{Binding Name}" />
                                                        <ListBox Margin="5" ItemsSource="{Binding Modifiers}" ItemTemplate="{StaticResource SelectedItemTemplate}" />
                                                    </StackPanel>
                                                </DataTemplate>
                                            </ItemsControl.ItemTemplate>
                                        </ItemsControl>
                                    </StackPanel>
                                </shared:ResizableContentControl>
                            </DataTemplate>
                        </shared:PopupButton.PopupContentTemplate>
                    </shared:PopupButton>
                </StackPanel>
            </DataTemplate>
Thanks,

Billy Jacobs

Comments (3)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Billy,

You have the DisplayMode set to Merged, so there is no normal "button" to fire the command. The Command is only used in the Split (for the left portion) and ButtonOnly display modes.

Actipro Software Support
Posted 5 years ago by Billy Jacobs
Is there any event that fires when the button is clicked to open the popup?

Thanks,

Billy Jacobs
Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
The PopupButton has the PopupOpened and PopupOpening events. Additionally, the PopupButton Features Demo shows how you can define a ContextMenu or PopupContent in XAML or dynamically during runtime.

Actipro Software Support

Add a Comment

Please log in to a validated account to post comments.