update sample code bind
This commit is contained in:
Родитель
3587c40991
Коммит
73e5f15b9d
|
@ -1,51 +1,50 @@
|
|||
private void SuggestingBox_OnPointerMoved(object sender, PointerRoutedEventArgs e)
|
||||
private void SuggestingBox_OnTokenPointerOver(RichSuggestBox sender, RichSuggestTokenPointerOverEventArgs args)
|
||||
{
|
||||
this._pointerPoint = e.GetCurrentPoint((UIElement)sender);
|
||||
}
|
||||
var flyout = (Flyout)FlyoutBase.GetAttachedFlyout(sender);
|
||||
var pointerPosition = args.CurrentPoint.Position;
|
||||
|
||||
private void SuggestingBox_OnTokenHovered(RichSuggestBox sender, RichSuggestTokenEventArgs args)
|
||||
{
|
||||
this._hoveringTimer.Debounce(() =>
|
||||
if (flyout?.Content is ContentPresenter cp && sender.TextDocument.Selection.Type != SelectionType.Normal &&
|
||||
(!flyout.IsOpen || cp.Content != args.Token.Item))
|
||||
{
|
||||
var flyout = (Flyout)FlyoutBase.GetAttachedFlyout(sender);
|
||||
if (flyout?.Content is ContentPresenter cp && sender.TextDocument.Selection.Type != SelectionType.Normal &&
|
||||
(!flyout.IsOpen || cp.Content != args.Token.Item))
|
||||
this._dispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
cp.Content = args.Token.Item;
|
||||
flyout.ShowAt(sender, new FlyoutShowOptions
|
||||
{
|
||||
Position = this._pointerPoint.Position,
|
||||
ExclusionRect = args.Rect,
|
||||
ShowMode = FlyoutShowMode.TransientWithDismissOnPointerMoveAway
|
||||
Position = pointerPosition,
|
||||
ExclusionRect = sender.GetRectFromRange(args.Range),
|
||||
ShowMode = FlyoutShowMode.TransientWithDismissOnPointerMoveAway,
|
||||
});
|
||||
}
|
||||
}, TimeSpan.FromMilliseconds(200));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void SuggestingBox_OnSuggestionChosen(RichSuggestBox sender, SuggestionChosenEventArgs args)
|
||||
{
|
||||
if (args.Prefix == "#")
|
||||
{
|
||||
args.Format.Background = Colors.DarkOrange;
|
||||
args.Format.Foreground = Colors.OrangeRed;
|
||||
args.Text = ((SampleDataType)args.SelectedItem).Text;
|
||||
args.Format.BackgroundColor = Colors.DarkOrange;
|
||||
args.Format.ForegroundColor = Colors.OrangeRed;
|
||||
args.Format.Bold = FormatEffect.On;
|
||||
args.Format.Italic = FormatEffect.On;
|
||||
args.DisplayText = ((SampleDataType)args.SelectedItem).Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Text = ((SampleEmailDataType)args.SelectedItem).DisplayName;
|
||||
args.DisplayText = ((SampleEmailDataType)args.SelectedItem).DisplayName;
|
||||
}
|
||||
}
|
||||
|
||||
private void SuggestingBox_OnSuggestionsRequested(RichSuggestBox sender, SuggestionsRequestedEventArgs args)
|
||||
private void SuggestingBox_OnSuggestionRequested(RichSuggestBox sender, SuggestionRequestedEventArgs args)
|
||||
{
|
||||
if (args.Prefix == "#")
|
||||
{
|
||||
sender.ItemsSource =
|
||||
this._samples.Where(x => x.Text.Contains(args.Query, StringComparison.OrdinalIgnoreCase));
|
||||
this._samples.Where(x => x.Text.Contains(args.QueryText, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.ItemsSource =
|
||||
this._emailSamples.Where(x => x.DisplayName.Contains(args.Query, StringComparison.OrdinalIgnoreCase));
|
||||
this._emailSamples.Where(x => x.DisplayName.Contains(args.QueryText, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
|
@ -83,7 +83,7 @@
|
|||
ClipboardCopyFormat="PlainText"
|
||||
ClipboardPasteFormat="PlainText"
|
||||
DisabledFormattingAccelerators="All"
|
||||
Header="Plain text suggest box with on token selected flyout"
|
||||
Header="Plain text suggest box with on token pointer over flyout"
|
||||
ItemTemplate="{StaticResource EmailTemplate}"
|
||||
Prefixes="@"
|
||||
FlyoutBase.AttachedFlyout="{StaticResource TokenSelectedFlyout}" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче