Mouse click event in BingAR

Feb 11, 2012 at 4:45 PM

Hi all,

How do I attach a mouse click event in the BingAR example? I tried adding

<Button x:Name="ButtonClick" Click="Button_Click" />

in the DataTemplate but is difficult to fire the event. My DataTemplate xaml:

 

<DataTemplate x:Key="RestaurantItem">
    		<Border BorderBrush="Black" BorderThickness="4" CornerRadius="8" Background="#FF003847" Width="320">
    			<Grid Margin="4">
    				<Grid.ColumnDefinitions>
    					<ColumnDefinition Width="Auto"/>
    					<ColumnDefinition Width="0.5*"/>
    				</Grid.ColumnDefinitions>
    				<Grid.RowDefinitions>
    					<RowDefinition Height="0.33*"/>
    					<RowDefinition Height="0.33*"/>
    					<RowDefinition Height="16"/>
    				</Grid.RowDefinitions>
					<Image Grid.RowSpan="3" Source="FastFood.png" Stretch="None" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,10,0"/>
    				<TextBlock x:Name="NameBlock" TextWrapping="NoWrap" Text="{Binding Name}" FontSize="32" VerticalAlignment="Center" Margin="0,0,4,0" d:LayoutOverrides="Width" Grid.Column="1" TextTrimming="WordEllipsis"/>
    				<TextBlock x:Name="TypeBlock" TextWrapping="NoWrap" Text="{Binding Cuisine}" FontSize="20" VerticalAlignment="Center" Margin="0,0,4,0" Grid.Column="1" d:LayoutOverrides="Width" Grid.Row="1" TextTrimming="WordEllipsis"/>
    				<ProgressBar x:Name="RatingBar" Grid.Row="2" Grid.Column="1" Maximum="10" Value="{Binding Rating}" VerticalAlignment="Center"/>
                    <Button x:Name="ButtonClick" Click="Button_Click" />
    			</Grid>
    		</Border>
    	</DataTemplate>

Thanks,

CG

 

Coordinator
Feb 14, 2012 at 7:53 PM

What do you mean it's difficult to fire the event? What happens when the button gets clicked?

Feb 25, 2012 at 4:48 AM

I solved the problem by adding Tap event to Grid instead :)