簡體   English   中英

WPF組合框可編輯,不可編輯

[英]WPF combobox iseditable not making editable

我有一個WPF表單,其中的文件夾中有一個帶項目的組合框。 我想使組合框可編輯。 這樣,當我鍵入一些單詞時,它應該打開帶有匹配視頻名稱的組合框。

WPF

<ComboBox x:Name="data" IsEditable="True" FontFamily="verdana" Text=""  FontSize="28" HorizontalAlignment="Left" Height="81" Margin="29,214,0,0" VerticalAlignment="Top" Width="326" SelectionChanged="data_SelectionChanged"/>
<ItemsControl Name="VideoList" ItemsSource="{Binding VideoList}" Margin="434,134,0,10" HorizontalAlignment="Left" Width="733">

.cs

public TextToSignWindow() //constructor
{
    InitializeComponent();
    var rootFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
    var root = rootFolder + @"\Videos\";
    string localPath = new Uri(root).LocalPath;
    PopulateListBox(data, localPath, " * .wmv ");
}

private void PopulateListBox(ComboBox cmb, string Folder, string FileType)
{
    DirectoryInfo dinfo = new DirectoryInfo(Folder);
    FileInfo[] Files = dinfo.GetFiles(FileType);
    foreach(FileInfo file in Files)
    {
        cmb.Items.Add(file.Name);
    }
}

您在尋找這樣的東西嗎

<ComboBox Grid.Column="3" Grid.Row="15" Height="Auto" HorizontalAlignment="Stretch" 
                Name="cmbName" VerticalAlignment="Stretch"
                SelectedItem="{Binding Name, Mode=TwoWay}"
                ItemsSource="{Binding GetAllName}">
            <TextSearch.TextPath>FirstName</TextSearch.TextPath>
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock DataContext="{Binding}">
                        <TextBlock.Text>
                            <MultiBinding StringFormat="{}{0} - {1}">
                                <Binding Path="FirstName" />
                                <Binding Path="LastName" />
                            </MultiBinding>
                        </TextBlock.Text>
                    </TextBlock>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM