AutoCompleteBox with Highlighted Text

2 posts, 0 answers
  1. Shilpa
    Shilpa avatar
    12 posts
    Member since:
    Mar 2013

    Posted 29 Jul 2013 Link to this post

    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 ?



  2. Shilpa
    Shilpa avatar
    12 posts
    Member since:
    Mar 2013

    Posted 30 Jul 2013 Link to this post

    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.]
  3. DevCraft banner
Back to Top