This is a migrated thread and some comments may be shown as answers.

AutoCompleteBox with Highlighted Text

1 Answer 58 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Shilpa
Top achievements
Rank 1
Shilpa asked on 29 Jul 2013, 12:15 PM
Hi there,

i am implementing a autocompletebox with Highlighted text. Following in XAML code,

<basicControls:AutoCompleteBox x:Name="quickSearch"
Style="{StaticResource SearchTextBoxStyle}" FilterMode="Contains"
SelectedItem="{Binding SelectedSearch, Mode=TwoWay}"
       KeyUp="quickSearchDiagrams_KeyUp" SelectionChanged="quickSearchDiagrams_SelectionChanged"
ValueMemberPath="FacilityAddress.AddressLine1">
   <basicControls:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<basicControls:HighlightingTextBlock x:Name="BCHighlightingTextBlock" Text="{Binding FacilityAddress.AddressLine1}"
HighlightedText="{Binding Text, ElementName=quickSearch,UpdateSourceTrigger=PropertyChanged}"
FilterMode ="Contains" ToolTipService.ToolTip="{Binding FacilityAddress.AddressLine1}" />
</DataTemplate>
</basicControls:AutoCompleteBox.ItemTemplate>
</basicControls:AutoCompleteBox>

The basicControls:HighlightingTextBlock is implementing the highlighting  functionality. Here if you see the basicControls:HighlightingTextBlock control
is taking value of  basicControls:AutoCompleteBox control as HighlightedText="{Binding Text, ElementName=quickSearch,UpdateSourceTrigger=PropertyChanged}". 
But Issue is, HighlightedText able to get the value only on first search action of page load and lost on scroll. But when tried search again then everything is working fine.
HighlitedText is a property defined as following, inside a class

public bool IsHighlighted
        {
            get;
            private set;
        }

Any idea about this issue ?



1 Answer, 1 is accepted

Sort by
0
Shilpa
Top achievements
Rank 1
answered on 30 Jul 2013, 06:57 AM
Hi !

I found that "HighlightedText" this dependent property was not having value on first search click when the url firstly requested and xaps are downloaded first time.  As of now i fixed this using following event call.

private void BCHighlightingTextBlock_OnSizeChanged(object sender, SizeChangedEventArgs e)
        {
            ((HighlightingTextBlock)sender).HighlightedText = quickSearchDiagrams.Text;
        }

and attached this as follows,

<basicControls:AutoCompleteBox.ItemTemplate>
                                        <DataTemplate>
                                            <basicControls:HighlightingTextBlock x:Name="BCHighlightingTextBlock" Text="{Binding FacilityAddress.AddressLine1}" 
                                                             HighlightedText="{Binding Path=Text, ElementName=quickSearchDiagrams,Mode=TwoWay}" 
                                                              SizeChanged="BCHighlightingTextBlock_OnSizeChanged"
                                                             FilterMode ="Contains" ToolTipService.ToolTip="{Binding FacilityAddress.AddressLine1}"
                                                             HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                                        </DataTemplate>
                                    </basicControls:AutoCompleteBox.ItemTemplate>


Thanks. [posted as if anyone is facing such issue. Or if someone having alternative to fix this issue.]
Tags
AutoCompleteBox
Asked by
Shilpa
Top achievements
Rank 1
Answers by
Shilpa
Top achievements
Rank 1
Share this question
or