File tree Expand file tree Collapse file tree 6 files changed +91
-0
lines changed
Microsoft.Toolkit.Uwp.SampleApp
Microsoft.Toolkit.Uwp.UI.Behaviors/Select Expand file tree Collapse file tree 6 files changed +91
-0
lines changed Original file line number Diff line number Diff line change 488488 <Compile Include =" SamplePages\AutoFocusBehavior\AutoFocusBehaviorPage.xaml.cs" >
489489 <DependentUpon >AutoFocusBehaviorPage.xaml</DependentUpon >
490490 </Compile >
491+ <Compile Include =" SamplePages\AutoSelectBehavior\AutoSelectBehaviorPage.xaml.cs" >
492+ <DependentUpon >AutoSelectBehaviorPage.xaml</DependentUpon >
493+ </Compile >
491494 <Compile Include =" SamplePages\CanvasPathGeometry\GeometryStreamReader.cs" />
492495 <Compile Include =" SamplePages\ColorPicker\ColorPickerButtonPage.xaml.cs" >
493496 <DependentUpon >ColorPickerButtonPage.xaml</DependentUpon >
614617 <Content Include =" SamplePages\Animations\Behaviors\RotateBehaviorXaml.bind" />
615618 <Content Include =" SamplePages\Animations\Effects\EffectAnimations.bind" />
616619 <Content Include =" SamplePages\VisualEffectFactory\VisualEffectFactory.bind" />
620+ <Content Include =" SamplePages\AutoSelectBehavior\AutoSelectBehaviorXaml.bind" />
617621 </ItemGroup >
618622 <ItemGroup >
619623 <Compile Include =" App.xaml.cs" >
951955 <SubType >Designer</SubType >
952956 <Generator >MSBuild:Compile</Generator >
953957 </Page >
958+ <Page Include =" SamplePages\AutoSelectBehavior\AutoSelectBehaviorPage.xaml" >
959+ <Generator >MSBuild:Compile</Generator >
960+ <SubType >Designer</SubType >
961+ </Page >
954962 <Page Include =" SamplePages\ColorPicker\ColorPickerButtonPage.xaml" >
955963 <Generator >MSBuild:Compile</Generator >
956964 <SubType >Designer</SubType >
Original file line number Diff line number Diff line change 1+ <Page x : Class =" Microsoft.Toolkit.Uwp.SampleApp.SamplePages.AutoSelectBehaviorPage"
2+ xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+ xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
4+ xmlns : behaviors =" using:Microsoft.Toolkit.Uwp.UI.Behaviors"
5+ xmlns : d =" http://schemas.microsoft.com/expression/blend/2008"
6+ xmlns : interactivity =" using:Microsoft.Xaml.Interactivity"
7+ xmlns : mc =" http://schemas.openxmlformats.org/markup-compatibility/2006"
8+ mc : Ignorable =" d" >
9+
10+ <Grid >
11+ <StackPanel HorizontalAlignment =" Center"
12+ VerticalAlignment =" Center" >
13+ <TextBox Text =" My content is not selected when loaded" />
14+ <TextBox Text =" My content is selected when loaded" >
15+ <interactivity : Interaction .Behaviors>
16+ <behaviors : AutoSelectBehavior />
17+ </interactivity : Interaction .Behaviors>
18+ </TextBox >
19+ </StackPanel >
20+ </Grid >
21+ </Page >
Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+ // See the LICENSE file in the project root for more information.
4+
5+ using Windows . UI . Xaml . Controls ;
6+
7+ namespace Microsoft . Toolkit . Uwp . SampleApp . SamplePages
8+ {
9+ /// <summary>
10+ /// A page that shows how to use the AutoSelectBehaviorPage
11+ /// </summary>
12+ public sealed partial class AutoSelectBehaviorPage : Page
13+ {
14+ public AutoSelectBehaviorPage ( ) => InitializeComponent ( ) ;
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+ xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
4+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+ xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
6+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+ mc:Ignorable="d">
8+
9+ <Grid>
10+ <StackPanel HorizontalAlignment="Center"
11+ VerticalAlignment="Center">
12+ <TextBox Text="My content is not selected when loaded" />
13+ <TextBox Text="My content is selected when loaded">
14+ <interactivity:Interaction.Behaviors>
15+ <behaviors:AutoSelectBehavior />
16+ </interactivity:Interaction.Behaviors>
17+ </TextBox>
18+ </StackPanel>
19+ </Grid>
20+ </Page>
Original file line number Diff line number Diff line change 857857 "Icon" : " /Assets/Helpers.png" ,
858858 "DocumentationUrl" : " https://raw.githubusercontent.com/MicrosoftDocs/WindowsCommunityToolkitDocs/master/docs/behaviors/FocusBehavior.md"
859859 },
860+ {
861+ "Name" : " AutoSelectBehavior" ,
862+ "Type" : " AutoSelectBehaviorPage" ,
863+ "Subcategory" : " Systems" ,
864+ "About" : " Behavior to automatically select the entire content of a TextBox control when it loads" ,
865+ "CodeUrl" : " https://github.com/windows-toolkit/WindowsCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI/Behaviors/" ,
866+ "XamlCodeFile" : " AutoSelectBehaviorXaml.bind" ,
867+ "Icon" : " /Assets/Helpers.png"
868+ },
860869 {
861870 "Name" : " Win2d Path Mini Language Parser" ,
862871 "Type" : " CanvasPathGeometryPage" ,
Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+ // See the LICENSE file in the project root for more information.
4+
5+ using Windows . UI . Xaml . Controls ;
6+
7+ namespace Microsoft . Toolkit . Uwp . UI . Behaviors
8+ {
9+ /// <summary>
10+ /// This behavior automatically selects the entire content of the associated <see cref="TextBox"/> when it is loaded.
11+ /// </summary>
12+ public sealed class AutoSelectBehavior : BehaviorBase < TextBox >
13+ {
14+ /// <inheritdoc/>
15+ protected override void OnAssociatedObjectLoaded ( ) => AssociatedObject . SelectAll ( ) ;
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments