Click here to Skip to main content
15,886,518 members
Articles / Desktop Programming / WPF

WPF AutoComplete Folder TextBox

Rate me:
Please Sign up or sign in to vote.
3.14/5 (10 votes)
3 Sep 2009CPOL3 min read 123K   3.6K   34  
This article demos how to create a textbox which can auto-suggest items at runtime based on input, in this case, disk drive folders.
<Window x:Class="AutoCompleteTextBox.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:t="clr-namespace:QuickZip.Tools"
    xmlns:local="clr-namespace:QuickZip.Controls" x:Name="root"
    Title="Window1" Height="300" Width="300">
    <DockPanel>
        <Border BorderBrush="Silver" BorderThickness="1" Padding="2" DockPanel.Dock="Bottom">
            <DockPanel >
                <local:SelectFolderTextBox  DockPanel.Dock="Bottom" Margin="4,0,0,0" />
                <local:SelectFolderTextBox  x:Name="stb" DockPanel.Dock="Bottom" Margin="4,0,0,0">
                    <local:SelectFolderTextBox.Text>
                        <Binding Path="Text" UpdateSourceTrigger="Explicit" >
                            <Binding.ValidationRules>
                                <t:DirectoryExistsRule />
                            </Binding.ValidationRules>
                        </Binding>
                    </local:SelectFolderTextBox.Text>
                </local:SelectFolderTextBox>
                <Label Content="_Enter Path" Target="{Binding ElementName=stb}"  />
            </DockPanel>
        </Border>
        <TextBlock Text="{Binding Text}" />
    </DockPanel>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder
Hong Kong Hong Kong

Comments and Discussions