locked
AutoComplete and Lookup Table RRS feed

  • General discussion

  • I am trying to create an autocomlete box that will reference a table.
    I have this currntly working using a List I create.

    XAML
    <StackPanel x:Name="LayoutRoot2" Background="White" Width="100">
        <sdk:AutoCompleteBox x:Name="MyAutoCompleteBox"  
                   IsTextCompletionEnabled="True"
                   ItemsSource="{StaticResource Items}" />
    </StackPanel>

    VB
    Partial Public Class BusinessList
        Inherits Page

        Private Items As New List(Of String)() From {"One", "Two", "Three", "Four"}

        Public Sub New()
            Me.Resources.Add("Items", Items)
            InitializeComponent()
        End Sub


    What I want to do is change the ItemsSource to look at a table...I tried this but its not working...
    I type in the box but it does not prompt me as it does above with the list.

    XAML
        <UserControl.Resources>
            <my1:DomainDataSource AutoLoad="True" x:Name="BusinessNameList" QueryName="GetTbl_BusinessNamesQuery"/>       
        </UserControl.Resources>

        <StackPanel x:Name="LayoutRoot2" Background="White" Width="100">
             <sdk:AutoCompleteBox x:Name="MyAutoCompleteBox"  
                        IsTextCompletionEnabled="True"
                        ItemsSource="{Binding Data, Source={StaticResource BusinessNameList}}" />
        </StackPanel>

    VB
    Partial Public Class BusinessList
        Inherits Page

        Dim ctx As New BusinessContext()

        Public Sub New()

            InitializeComponent()

            Dim ds As DomainDataSource = TryCast(Me.Resources("BusinessNameList"), DomainDataSource)
            ds.DomainContext = ctx
            ds.Load()

        End Sub


    ANY THOUGHTS as to what I am missing here?

    Thursday, March 15, 2012 1:46 PM

All replies

  •  I got it working in a DataGrid but Cant seem to get it working in a Child Windows Dataform

    DATAGRID
        <UserControl.Resources>
            <my1:DomainDataSource AutoLoad="False" x:Name="BusinessNameList" QueryName="GetTbl_BusinessNamesQuery" LoadedData="BusinessesTable_LoadedData"/>
        </UserControl.Resources>

    <sdk:AutoCompleteBox x:Name="MyAutoCompleteBox"  FilterMode="Contains"
             IsTextCompletionEnabled="True"
             ItemsSource="{Binding Data, Source={StaticResource BusinessNameList}}"
             Text="{Binding BusinessName, Mode=TwoWay}"/>

     

    I tried this in the Child Window dataform BUT GET AN ERROR
    ERROR:
    The property 'Resources' does not exist on the type 'ChildWindow' in the XML namespace
    'clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls'. 

    DATAFORM IN CHILD WINDOW
        <UserControl.Resources>
            <my1:DomainDataSource AutoLoad="False" x:Name="BusinessNameList" QueryName="GetTbl_BusinessNamesQuery" />
        </UserControl.Resources>

            <dataForm:DataForm x:Name="BusinessDatabaseEditForm" Header="Map Library Edit Record" Width="425" Height="700"
                           HorizontalAlignment="center" AutoGenerateFields="False" AutoEdit="False" CurrentItem="{Binding}"
                           AutoCommit="True"  Margin="0,12,0,0"
                           CommandButtonsVisibility="Edit, Commit, Cancel" BorderThickness="0" >
                <dataForm:DataForm.EditTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical" Width="Auto" Height="Auto">                      
                            <dataForm:DataField Label="Auto Complete Box" >
                                <sdk:AutoCompleteBox x:Name="MyAutoCompleteBox"  FilterMode="Contains"
                                       IsTextCompletionEnabled="True"
                                       ItemsSource="{Binding Data, Source={StaticResource BusinessNameList}}"
                                       Text="{Binding BusinessName, Mode=TwoWay}"/>
                            </dataForm:DataField>
                        </StackPanel>
                    </DataTemplate>
                </dataForm:DataForm.EditTemplate>
            </dataForm:DataForm>

    Friday, March 16, 2012 12:40 PM
  • I think my problem is the resources and how I am trying to get to the Query and Domian

    <controls:ChildWindow x:Class="BusinessApplication4.BusinessDatabaseEditRecord"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
               xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk
               xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
               xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
               xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"  
               Loaded="UserControl_Loaded"
               Closed="UserControl_Closed"
                         
               xmlns:my2="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices">
       

        <Control.Resources>
            <DropShadowEffect x:Name="miniDropShadow" BlurRadius="5" ShadowDepth="5" Direction="-45" Color="Black" Opacity="0.5" />
            <my2:DomainDataSource AutoLoad="False" x:Name="BusinessNameList" QueryName="GetTbl_BusinessNamesQuery" />
        </Control.Resources>

    Friday, March 16, 2012 12:49 PM
  • Changed to this ...NO MORE ERROR but nothing is shoing up in the combobox or working in the AutoPopulate box...
    ALTHOUGH this works as is in my Main.xaml...something is wrong in the child window...the child window cant find the Domain????

    Do I have to spell out the path to the Child Window in the Query Name below?  I think its not getting back to the Query or soemthing....Any thoughts?

        <controls:ChildWindow.Resources>
             <my2:DomainDataSource AutoLoad="False" x:Name="BusinessNameList3" QueryName="GetTbl_BusinessNamesQuery" />
        </controls:ChildWindow.Resources>
       

            <dataForm:DataForm x:Name="BusinessDatabaseEditForm" Header="Map Library Edit Record" Width="425" Height="700"
                           HorizontalAlignment="center" AutoGenerateFields="False" AutoEdit="False" CurrentItem="{Binding}"
                           AutoCommit="True"  Margin="0,12,0,0"
                           CommandButtonsVisibility="Edit, Commit, Cancel" BorderThickness="0" >
                <dataForm:DataForm.EditTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical" Width="Auto" Height="Auto">

                            <dataForm:DataField Label="Business Name" >
                                <ComboBox ItemsSource="{Binding Data, Source={StaticResource BusinessNameList3}}" 
                                         SelectedItem="{Binding BusinessName, Mode=TwoWay}"
                          DisplayMemberPath="BusinessName"  />
                            </dataForm:DataField>
                           
                            <dataForm:DataField Label="Auto Complete Box" >
                                <sdk:AutoCompleteBox x:Name="MyAutoCompleteBox"  FilterMode="Contains"
                                                            IsTextCompletionEnabled="True"
                                                            ItemsSource="{Binding Data, Source={StaticResource BusinessNameList3}}"
                                                            Text="{Binding BusinessName, Mode=TwoWay}"/>
                            </dataForm:DataField>                    
                        </StackPanel>
                    </DataTemplate>
                </dataForm:DataForm.EditTemplate>
            </dataForm:DataForm>
           

    Friday, March 16, 2012 1:01 PM
  • THINK I GOT IT....BRB....

    Will paste all my code as well.....

     

    Friday, March 16, 2012 1:44 PM
  • I got it to work..Sort of..but I want this to be an edit to existing record...if I leave it a simply combobox
    it automatically changes it to the first record in the lookup table....it works for a new record but not so much for
    an existing record..
    In the main datagrid I am doing this....

      <my:DataGridTemplateColumn Header="Business Name">
           <my:DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                   <TextBlock Text="{Binding BusinessName}" />
               </DataTemplate>
           </my:DataGridTemplateColumn.CellTemplate>
           <my:DataGridTemplateColumn.CellEditingTemplate>
               <DataTemplate>
                   <ComboBox ItemsSource="{Binding Data, Source={StaticResource BusinessNameList}}" 
                             SelectedItem="{Binding BusinessName, Mode=TwoWay}"
                             DisplayMemberPath="BusinessName"  />
               </DataTemplate>
           </my:DataGridTemplateColumn.CellEditingTemplate>
       </my:DataGridTemplateColumn>         
      
     
    So I am looking to changes the below to reflect the above...CAN THIS BE DONE?
    Can I make a CellTemplete and a CellEditTEmplate inside a DATAFORM????

      <dataForm:DataField Label="Business Name" >
          <ComboBox ItemsSource="{Binding Data, Source={StaticResource BusinessNameList}}" 
                   SelectedItem="{Binding BusinessName, Mode=TwoWay}"
             DisplayMemberPath="BusinessName"  />
      </dataForm:DataField>

     

     

    Friday, March 16, 2012 2:54 PM
  • Cant figure out how to do this in a dataform....I was the person to be able to click the record on the main Datagrid.  THen have a child window open that will allow them to make changes to that record...That works up to this point...
    BUT when I bring in the combobox it changes the value to the first one in the combobox list????
    As you can see from the code above in the DataGrid there is a CellTemplate and CellEditingTemplate that stops this from happening...BUT I cannot figure out how to do this in the DataForm

    Please help...thanks..all your help is greatly appreciated.

    Monday, March 19, 2012 9:34 AM
  • Has anyone out there attempted and was succesful in using a AutoComplete in a DataFORM that references values from a table in their project....I have been looking everywhere for this...

    I can do it for a DataGRID but not the DataFORM????  PLease see above for my code that I am trying....having a very hard time with the Combobox and AutoComplete in the DataFORM....I can do both in the DataGRID...uggggg

    Thanks

    Tuesday, March 20, 2012 4:00 PM