Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24030 |

    What controls the Display of the CurrentValue in a ComboBox WHEN the DropDown is activated ?

    The Grid has the following relevant settings (as it explains the initial display and subsequent behaviour).

    EditTriggers =”CellIsCurrent”
    CellEditorDisplayConditions=”RowIsBeingEditing”

    When I first display the grid…the ComboBox field is displayed correctly without the drop down arrow..as expected. (I also have the Item field displayed as a TextBox which helps me see the actual value of the field and whether the reverse binding is working).

    Now I have 2 ObjectDataSources: one for the Grid (Items) and the other for the valid items in the ComboBox.

    ========= Grid Data Source ====================
    <ObjectDataProvider x:Key=”ods_ServicesLanguageSubItemData” ObjectType=”{x:Type ds_screen:LanguageSubItemCollection}” />
    =========================================
    =========ComboBox DataSource =================
    <ObjectDataProvider x:Key=”ods_ServicesLanguageData” ObjectType=”{x:Type ds_screen:LanguageItemCollection}” />

    The Grid data name for the field is ‘LanguageID’ (in ods_ServicesLanguageSubItemData) whereas the ComboBox dataname is ‘Code’ (in ods_ServicesLanguageData)

    The ComboBox is declared….

    <ComboBox
    MinHeight=”22″
    VerticalContentAlignment=”Top”
    SelectedValue=”{xcdg:CellEditorBinding}”
    ItemsSource=”{Binding Source={StaticResource ods_ServicesLanguageData}}”
    ItemTemplate=”{StaticResource languageidDataTemplate}”
    SelectedValuePath=”Code”
    DisplayMemberPath=”Code”
    IsSynchronizedWithCurrentItem=”False”
    Foreground=”{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(TextElement.Foreground)}”
    >
    <ComboBox.Resources>
    <Style TargetType=”Popup”>
    <Setter Property=”TextElement.Foreground”
    Value=”{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}” />
    </Style>
    </ComboBox.Resources>

    I have a Data Template or the ComboBox…which has a binding to the ComboBox DataSource field.

    <DataTemplate x:Key=”languageidDataTemplate”>
    <TextBlock Text=”{Binding Code}”
    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>

    OK…as soon as I enter a row the ComboBox Arrow appears in the field but the value is blanked out….
    I Drop down the Combo box and the values are displayed…but still nothing at the top.
    I select a value (ENTER) and the binding works…i.e. the other TextBox field is NOW updated.
    Now, this is REALLY The strange bit…All ComboBox Fields that I have UPDATED and revisit the row DO show the current value correctly and even when I do a dropdown the value is still shown at the top…but all thos I haven’t updated are blan on a visit.

    Any ideas ???

    Imported from legacy forums. Posted by Desmond (had 740 views)

    User (Old forums)
    Member
    Post count: 23064

    you are binding with selected value not the text.
    the text is sometimes the selected value. When you first start the selected value is not set or matching because your cells value is not an object in the combobox. once you select an item the cells value is now related to the comboboxes current value.
    If that all makes sense

    Imported from legacy forums. Posted by MiddleTommy (had 311 views)

    User (Old forums)
    Member
    Post count: 23064

    Many thanks Tommy….

    So…how would I ‘populate’ the SelectedValue with the value that is actually there ?

    Cheers,

    Dezzz.

    Imported from legacy forums. Posted by Desmond (had 258 views)

    User (Old forums)
    Member
    Post count: 23064

    I am still working on that
    What I did is make the combobox editable
    and bind to the Text property not the selected value
    so my users can type with auto complete or select from the combobox list

    I am still working out how to Force a user to select one of the items in the list when the combobox is editable.

    Imported from legacy forums. Posted by MiddleTommy (had 439 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Tommy…

    I think I have the ‘root’ of the problem….

    The Data that I was pulling from the Database had darned trailing spaces in it !!!

    The Code had “de ” whereas the LanguageID had “de” . It is no wonder I couldn’t SEE the problem.

    Sorry to lead you on a merry go round…

    Still a lesson to be learned there…

    Imported from legacy forums. Posted by Desmond (had 235 views)

    User (Old forums)
    Member
    Post count: 23064

    No problem
    This is one I just started working on
    And still have the problems discussed because my combobox is bound to a collection of objects and not just a list of strings

    Imported from legacy forums. Posted by MiddleTommy (had 312 views)

    User (Old forums)
    Member
    Post count: 23064

    OK Tommy…let’s see if I can help…..the area where I THOUGHT I had the problem was in the ObjectDataProvider.

    Basically the way it works or more to the point the way most of the examples seem to show… is that the Constructor of the Object Collection adds a few records which populates the collection. In the real world this rarely happens.

    So…I have an Observable Collection with a constructor that does nothing useful (i.e. doesn;t add records).

    Now in the code behind I have the following code…JUST after the Initialize.

    ObjectDataProvider _ObjectServiceProvider_Direction = (ObjectDataProvider)FindResource(“myDirections”);
    DirectionCollection _DirectionCollection = new DirectionCollection();
    _DirectionCollection = (DirectionCollection)_ObjectServiceProvider_Direction.Data;

    _DirectionCollection.Add(new Direction(“North”, “Brrr…the cold North”));
    _DirectionCollection.Add(new Direction(“South”, “Ah..the Beautiful South”));
    _DirectionCollection.Add(new Direction(“East”, “The Mystical East”));
    _DirectionCollection.Add(new Direction(“West”, “Where the Sun Sets”));

    Now of course in the Real World you would typically read these 4 records from a supplied DataSource, a Service or whatever…

    What you have done here is effectively glue the XAML

    <Window.Resources>
    <ObjectDataProvider x:Key=”myDirections” ObjectType=”{x:Type ds:DirectionCollection}” />

    to an instance that you create in code.

    Does this help at all ???

    Dezzz.

    Imported from legacy forums. Posted by Desmond (had 210 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks Deez that wasnt my problem
    I can populate comboboxes easily in code behind
    for short lists the easiest way is just populate the combobox on the dropdownopen event

    for big lists I populate a collection before and add it as a resource in C# before the xaml is loaded so in the xaml I can uses that resource.

    I was just figuring out the behavior of comboboxes during runtime to suit my needs

    Imported from legacy forums. Posted by MiddleTommy (had 5732 views)

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.