views:

215

answers:

1

Hi,I have textblcok in my listbox as listboxitem.When i seelct the item in that,it shows blue in color.I dont want that.How can i remve that. My XAML:

<ListBoxItem>
                <StackPanel Margin="10,5,0,0" Name="Stack1" Orientation="Horizontal">
                    <Image  Margin="10,0,0,0" Name="Img1" Height="15"></Image>
                    <TextBlock Margin="10,0,0,0" Name="Text1" Width="271"></TextBlock>
                </StackPanel>
            </ListBoxItem>            
            <ListBoxItem>
                <StackPanel Margin="10,5,0,0" Name="Stack2" Orientation="Horizontal">
                    <Image  Margin="10,0,0,0" Name="Img2" Height="15" HorizontalAlignment="Center" VerticalAlignment="Center"></Image>
                    <TextBlock Margin="10,0,0,0" Name="Text2" Height="15" Width="271"></TextBlock>
                </StackPanel>
            </ListBoxItem>
            <ListBoxItem>
                <StackPanel Margin="10,5,0,0" Orientation="Horizontal">
                    <Image  Margin="10,0,0,0" Name="Img3" Height="15"></Image>
                    <TextBlock Margin="10,0,0,0" Name="Text3" Width="271"></TextBlock>
                </StackPanel>
            </ListBoxItem>
        </ListBox>

Selection coding in C#:

private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

            int index = listBox1.SelectedIndex;
            string str;
            if (index == 0)
            {
                 str = (string)Text1.Text;
            }
            else if (index == 1)
            {
                 str = (string)Text2.Text;
            }
            else
            {
                 str = (string)Text3.Text;
            }

            MessageBox.Show(str);            

        }