Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF Command Binding Doesnt work always on a button

$
0
0

Please advise. Command binding on the button fires if I click on any text block or image that comes from the Content Control. But if I click on any empty area it doesn't fire.

       <ItemsControl x:Name="Name"
Grid.Column="0"
ItemsSource="{Binding Source}"
VerticalContentAlignment="Stretch"
Margin="5">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Columns="2"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Button x:Name="Button" Command="{Binding DataContext.PauseCommand,
                        RelativeSource={RelativeSource FindAncestor,AncestorType=UserControl}}"
                 CommandParameter="{Binding}">
                        <Button.Style>
                            <Style TargetType="Button">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <ContentControl Content="{Binding}" ContentTemplate="{StaticResource BindableTemplate}"/>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Button.Style>
                       
                    </Button>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>