Home Forums WPF controls Xceed Toolkit Plus for WPF WatermarkCombobox DisplayMemberPath problem

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • molnard
    Participant
    Post count: 2
    #43617 |

    Hi,

    I have a DataGridControl and one of it Column set like this:

            <xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource Mylist}}">
                <xcdg:DataGridControl.Columns>
                    <xcdg:Column FieldName="MyProperty"
                                 CellContentTemplate="{StaticResource Celldatatemplate}" 
                                 CellEditor="{StaticResource categoryEditor}"/>
                </xcdg:DataGridControl.Columns>
            </xcdg:DataGridControl>

    I also defined some resources:

                <DataTemplate x:Key="Celldatatemplate" DataType="local:Class1">
                    <TextBlock Text="{Binding Path=Prop1}"></TextBlock>
                </DataTemplate>
    
                <!-- This is a very straightforward ComboBox editor used for the Category Column. -->
                <xcdg:CellEditor x:Key="categoryEditor">
                    <xcdg:CellEditor.EditTemplate>
                        <DataTemplate>
                            <!-- We prefer a BorderThickness of 0 but some ComboBox templates may 
                           ignore this preference (in Classic Theme for instance). -->
                            <!-- Notice the MinHeight set to the same value as the Cell previously. -->
                            <!-- The important glue mechanism is CellEditorBinding that takes care 
                           of creating the Binding with the Cell's value. -->
                            <xctk:WatermarkComboBox
                                SelectedValue="{xcdg:CellEditorBinding}"
                                ItemsSource="{Binding Path=MyComboboxList, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}"
                                      DisplayMemberPath="Prop1"
                                >
                            </xctk:WatermarkComboBox>
                        </DataTemplate>
                    </xcdg:CellEditor.EditTemplate>
    
                </xcdg:CellEditor>
    
    

    When I drop down my combobox the class name appears as the text of the combobox. Very similar like this problem:
    http://stackoverflow.com/questions/33175983/how-to-select-item-displayed-by-displaymemberpath-in-wpf-combobox

    If I change to standard Combobox everything works fine. Why DisplayMemberPath not working like at standart combobox? How can I solve this?

    If I override ToString method at my class it is also working. But I would like to use CellContentTemplate that is why I defined it.

    Thank you for your help!

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    My suggestion would have been to override the ToString method. However, since you mentioned that this is happening only with the Toolkit ComboBox and not the default one, could you send me a simple stand alone sample project which reproduces the issue so that I could have a closr look. You may send it to: support@xceed.com

    molnard
    Participant
    Post count: 2

    Hi Fawzi,

    I sent you a simple project by email, the problem is on this picture
    http://postimg.org/image/4suntlymp/

    xaml:

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="30"></RowDefinition>
                <RowDefinition Height="30"></RowDefinition>
            </Grid.RowDefinitions>
            <Label Content="WPF Combobox"></Label>
            <Label Grid.Row="0" Grid.Column="1" Content="WPF Combobox"></Label>
            <ComboBox Grid.Row="1" Grid.Column="0" ItemsSource="{Binding Class1S}" SelectedValuePath="Id" DisplayMemberPath="Text" SelectedValue="{Binding Path=Cathegory1, ValidatesOnExceptions=True }"></ComboBox>
            <xctk:WatermarkComboBox x:Name="ComboBox" Grid.Row="1" Grid.Column="1" SelectedValuePath="Id" ItemsSource="{Binding Class1S}" DisplayMemberPath="Text" SelectedValue="{Binding Path=Cathegory1, ValidatesOnExceptions=True }" />
    
        </Grid>

    window:

            public List<Class1> Class1S
            {
                get { return _class1S; }
                set { _class1S = value; }
            }
    
            private int _cathegory1;
            private List<Class1> _class1S = new List<Class1>();
    
            public int Cathegory1
            {
                get
                {
                    return _cathegory1;
                }
                set
                {
                  
                    _cathegory1 = value;
                }
            }
    
            public MainWindow()
            {
                InitializeComponent();
                DataContext = this;
            }

    class:

        public class Class1
        {
            public string Text { get; set; }
            public int Id { get; set; }
          
        }

    Dave

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