Welcome to the Xceed Community Sign in | Join | Help
Community Search  

ComboBox display persitence

Sort Posts: Previous Next
  •  05-13-2008, 6:03 AM Post no. 12198

    ComboBox display persitence

    Hello,

    How can i make the selected display appear in the editor box after i select an item, for example if i have a user with userId = 1 , and userFirstname = John, i have SelectedValuePath="userId", DisplayMemberPath="userFirstname" in the dropdown i see john but when i select john and move to another cell i get the userId 1 displayed in the editor box. and i have SelectedValue="{xcdg:CellEditorBinding}" in the ComboBox tag.

    Thank you 

  •  05-13-2008, 8:35 AM Post no. 12208 in reply to 12198

    Re: ComboBox display persitence

    You will also need to set create a CellContentTemplate if you want to display a value other than the ID when a cell is not being edited.
    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  05-14-2008, 2:49 PM Post no. 12266 in reply to 12208

    Re: ComboBox display persitence

    Jenny, can you give an example? I have set combo box to dictionary and everything is working ok. When I'm in edit mode I get text instead ID value. I can select and change value. Value is writen in collection. But when cell is not being edited ID (integer) value is shown again. My data template:

    <DataTemplate x:Key="pDataTemplate">
      <TextBlock Text="{Binding}"                           
        TextTrimming="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type xcdg:Cell}}, Path=ParentColumn.TextTrimming}"
        TextWrapping="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type xcdg:Cell}}, Path=ParentColumn.TextWrapping}"/>
    </DataTemplate>

    and in code:

        DataTemplate template = new DataTemplate();
        FrameworkElementFactory factory = new FrameworkElementFactory(typeof(ComboBox));
        factory.SetValue(ComboBox.ItemsSourceProperty, PList);
        factory.SetValue(ComboBox.DisplayMemberPathProperty, "Value");
        factory.SetValue(ComboBox.SelectedValuePathProperty, "Key");
        CellEditorBindingExtension binding = new CellEditorBindingExtension();
        factory.SetValue(ComboBox.SelectedValueProperty, binding);
        template.VisualTree = factory;

        Column column = this.Table.Columns["p_id_fk"];
        CellEditor cellEditor = new CellEditor();
        cellEditor.EditTemplate = template;
        column.CellEditor = cellEditor;
        column.CellContentTemplate = this.grid1.FindResource("pDataTemplate") as DataTemplate;
        column.CellEditorDisplayConditions = CellEditorDisplayConditions.MouseOverCell;
     

    How to set Text binding to get text description instead of ID? I try all sort of things (also with converter) but only in example above I managed to get at least column value (ID). If I set path to some value (ex. column name {Binding Path=p_id_fk} I get all blanks). I've looked at solidFoundation example but I have grid data source in observable collection. I believe I can't use DataTableDictionary class. Is there something like ObservableCollectionDictionary class?

    Can you help me please? 

     

  •  05-14-2008, 2:52 PM Post no. 12267 in reply to 12266

    Re: ComboBox display persitence

    http://xceed.com/CS/forums/post/11814.aspx
    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  05-14-2008, 3:04 PM Post no. 12269 in reply to 12267

    Re: ComboBox display persitence

    Hi, 

    If i am binding in code behind not in xaml code like in the ComboBox_Initialized function, if i assign the fields in binding property for the textblock tag i get an error saying that i cant use binding before initialization of the control, so what is the way to do it if i am binding in code behind?

    Thanks 

  •  05-14-2008, 5:32 PM Post no. 12278 in reply to 12269

    Re: ComboBox display persitence

    Try the Loaded event instead.

    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.