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

Button Command is not working in Nested Visual Tree(In WPF) ???

$
0
0

I am using Many Data Template to load the different - different views on Run Time  see below example of 1 Data template. In this i am using nested panels and containers and with in that there is a button with a Command.

                                                                                                                                                           In this structure when i tries to executes the command it doesn't. The control doesn't goes to command in View Model section.

<DataTemplate x:Key="View1"><DataTemplate.Resources><ResourceDictionary Source="/Project;Component/Resource/Resource.xaml"></ResourceDictionary></DataTemplate.Resources><ScrollViewer Style="{StaticResource ScrollViewerStyle1}" VerticalScrollBarVisibility="Auto" Width="500"

Height="400" HorizontalContentAlignment="Center" VerticalAlignment="Top"><ItemsControl ItemsSource="{Binding Path=Collection}"><ItemsControl.ItemTemplate><DataTemplate><StackPanel><StackPanel.Resources><Utility:CommandParameterConverter x:Key="CommandParameterConverter"/><VM:CategoryViewModel x:Key="CategoryViewModel"/><ImageBrush x:Key="ButtonBackGroundImage"

ImageSource="/Project;component/Images/img.png"></ImageBrush></StackPanel.Resources> <Button Tag="{Binding Id}" Command="{Binding Path=CategoryCommand}"><TextBlock Text="{Binding Item}" TextWrapping="Wrap" TextAlignment="Center"/><Button.CommandParameter><MultiBinding Converter="{StaticResource CommandParameterConverter}"><Binding Path="Tag" ElementName="CategoryBtn"></Binding><Binding Path="Content" ElementName="CategoryBtn"></Binding></MultiBinding></Button.CommandParameter> </Button></StackPanel></DataTemplate></ItemsControl.ItemTemplate></ItemsControl></ScrollViewer></DataTemplate>

But when i removed the <ScrollViewer></ScrollViewer> from above code it works fine very well, Why this is happening ???

And how to get invoked the Command parameter of Button when the Scroll Viewer is in the Data Template ???

Thanks & Regards

Ashutosh


Ashutosh Tiwari


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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