2014-02-07 71 views
0

如何實現這個UI?帶圖像的水龍頭列表框

item1 | X item2 | X item3 | X

與項目1,項目2,項目3已經SelectionChanged事件,X是用自來水事件的圖像

我想這

<telerikPrimitives:RadDataBoundListBox 
    x:Name="AddressListBox" 
    ItemsSource="{Binding hereRestAddressDetail}" 
    SelectedItem="{Binding hereRestDetail}" 
    SelectionChanged="AddressListBox_SelectionChanged" 
    ItemAnimationMode="PlayAll" 
    EmptyContent=""> 
    <telerikPrimitives:RadDataBoundListBox.ItemTemplate> 
     <DataTemplate> 
      <Grid Margin="0,0,0,10"> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="Auto"/> 
        <ColumnDefinition Width="*"/> 
        <ColumnDefinition Width="Auto" /> 
       </Grid.ColumnDefinitions> 
       <Grid.RowDefinitions> 
        <RowDefinition Height="*" /> 
        <RowDefinition Height="Auto" /> 
       </Grid.RowDefinitions> 

       <Rectangle Grid.Column="0" Grid.RowSpan="2" Width="10"> 
        <Rectangle.Fill> 
         <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/> 
        </Rectangle.Fill> 
       </Rectangle> 
       <StackPanel Grid.Column="1" Grid.RowSpan="2" > 
        <StackPanel Orientation="Horizontal"> 
         <TextBlock Text="{Binding LocalizedResources.by, 
              Source={StaticResource LocalizedStrings}}" 
            Style="{StaticResource PhoneTextNormalStyle}"/> 
         <TextBlock Text="{Binding creator}" Margin="-8,0,0,0" 
            Style="{StaticResource PhoneTextAccentStyle}"/> 
        </StackPanel> 
        <TextBlock Text="{Binding street}" 
           TextWrapping="Wrap" 
           Style="{StaticResource PhoneTextLargeStyle}" /> 
        <TextBlock Text="{Binding formatedStreet}" 
           TextWrapping="Wrap" 
           Style="{StaticResource PhoneTextSubtleStyle}" /> 
       </StackPanel> 
       <Image Source="{Binding ratingButton}" Grid.Column="2" 
         Stretch="Uniform" Width="80" 
         Tag="{Binding Id}" Tap="rate_Tap"/> 
       <TextBlock Text="{Binding ratingValue}" HorizontalAlignment="Center" 
          TextWrapping="Wrap" Grid.Column="2" Grid.Row="1" 
          Style="{StaticResource PhoneTextSubtleStyle}"/> 
      </Grid> 
     </DataTemplate> 
    </telerikPrimitives:RadDataBoundListBox.ItemTemplate> 

</telerikPrimitives:RadDataBoundListBox> 

但是當我挖掘到的圖像會執行我的事件(在本條件我只是測試它顯示messagebox),但之後,它也執行我的SelectionChanged事件...

如何指定只有圖像點擊事件,當我點擊圖像觸發?

回答

0

這應該工作:

bool ignoreSelectionChanged; 
void rate_Tap(...) { 
    ignoreSelectionChanged = true; 
    //do you image tap things here 
} 
void AddressListBox_SelectionChanged(...) { 
    if(ignoreSelectionChanged) { 
     ignoreSelectionChanged = false; //reset the bool, so that it will skip only once 
     return; 
    } 
    //do your things on selection change here 
}