Hello,
I need to show in a comboboxcolumn two properties of a complex object.
To achieve that I used the ValueConverter but it doesn't show me anything.
I attached a sample to show you how I do it.
Regards.
Hello Coso,
In the ComboBoxColumn set the SelectedValuePath and DisplayMemberPath properties.
Let me know if I can provide any further assistance.
Hello Duane,
I set the displamemberpath and selectedValuePath to property "Rue" but it doesn't work either.
One option is to wrap the int value in another object which exposes the int value and use a toString() method to display the text in the Filter Selection Control and implements IComparable for filtering.
Another option is to change the ItemTemplate used by the List Box (named itemsBox) in the FilterSelectionControl to use a converter to display the text instead of the int value as is done for the Label. When doing this, the one issue is that the List Box defined in the Style for the FilterSelectionControl is used by all columns, therefore the DataTemplate used for the ItemTemplate would need to change based on the Column. I have attached a sample illustrating this where I use the Loaded Event of the Listbox to set the appropriate DataTemplate.
Details on the implementation are as follows:
I have defined two data templates to use for the ItemTemplate of the List Box, one using the converter one with the original implementation:
<DataTemplate x:Key="NormalFilter"> <CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay Content="{Binding ContentString}" IsThreeState="False" /> </DataTemplate> <DataTemplate x:Key="CoteFilter"> <CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay Content="{Binding ContentString, Converter={StaticResource ConvertisseurPerso2}}" IsThreeState="False" /> </DataTemplate>
<DataTemplate x:Key="NormalFilter">
<CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay
Content="{Binding ContentString}" IsThreeState="False" />
</DataTemplate>
<DataTemplate x:Key="CoteFilter">
<CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay Content="{Binding ContentString,
Converter={StaticResource ConvertisseurPerso2}}" IsThreeState="False" />
The ListBox (itemsBox) in the FilterSelectionControl is changed to handle the Loaded event where the ItemTemplate will be set based on the column name. I have also binded the Tag property to the Column Name to easily implement the selection of the template in the Loaded event:
<Style TargetType="igPrim:FilterSelectionControl"> <Setter Property="Foreground" Value="#FF000000"/> … <ListBox x:Name="itemsBox" ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=UniqueValues}" Padding="0" Loaded="itemsBox_Loaded" Tag="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Cell.Column.DisplayNameResolved}" Background="Transparent" > </ListBox> ...
<Style TargetType="igPrim:FilterSelectionControl">
<Setter Property="Foreground" Value="#FF000000"/>
…
<ListBox x:Name="itemsBox"
ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=UniqueValues}"
Padding="0" Loaded="itemsBox_Loaded" Tag="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=Cell.Column.DisplayNameResolved}" Background="Transparent" >
</ListBox>
...
The loaded event gets the correct DataTemplate from the grid’s resources and sets the Item Template:
private void itemsBox_Loaded(object sender, RoutedEventArgs e) { ListBox lb = (ListBox)sender; string name = lb.Tag as string; if (name == "Côté") lb.ItemTemplate = (DataTemplate)this.xamGrid1.Resources["CoteFilter"]; else lb.ItemTemplate = (DataTemplate)this.xamGrid1.Resources["NormalFilter"]; }
private void itemsBox_Loaded(object sender, RoutedEventArgs e)
{
ListBox lb = (ListBox)sender;
string name = lb.Tag as string;
if (name == "Côté")
lb.ItemTemplate = (DataTemplate)this.xamGrid1.Resources["CoteFilter"];
else
lb.ItemTemplate = (DataTemplate)this.xamGrid1.Resources["NormalFilter"];
}
Please let me know if you have any questions.
Sincerely,
Valerie
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hello Valerie,
Thanks for your response, in my case I should choose the first solution. I tried something but now I have a problem with an unbound column.
To access my data I need this unbound column but the filter menu doesn't show any rows in the Listbox. I read the topic to create a custom filter but it shows how to for the filter menu on the top row.
Is there a way to apply a custom filter in the filter menu ?
I attached a sample to show you the modifications.
For filtering you should use a bound column. I have attached your updated sample using a Template Column as opposed to an Unbound Column.
Please let me know if this resolves your issue.
Thanks for your help I could achieve my goal with all your answers.
I still have a question, why can't we apply filter on an UnboundColumn when the property AllowFiltering is set to FilterMenu ?
Obviously it's possible when this property is set to FilterRowTop (according to the topic : http://help.infragistics.com/NetAdvantage/Silverlight/2012.2/CLR4.0/?page=xamGrid_Create_a_Custom_Filter.html).
FilterMenu with Unbound Column is unsupported since 10.1.
Sincerely,ValerieDeveloper Support Engineer Infragisticswww.infragistics.com/support
Thank you for sharing your solution.
Sorry for the late answer, I found a solution by adding a partial class with my data where I put a property that represent what I need.
With this I can use a TextColumn and filter it.
Thanks for your help.
Do you have any other questions on this matter?
The issue is that the underlying value of the cell does not contain the full text that is populated during the display using the converter. Therefore when filtering, the filter is taking the value displayed in the listbox (ex Nom + Prenom) and trying to compare this to the partial value in the cell (ex Nom). Using MVVM the idea would be that your data is represented as it is maintain in your model and then the classes can be refactored in your ViewModel to support binding to the view. This would be your best and simplest approach to resolving this issue.
Thanks for your response. But I can't change my data representation, so I tried a last solution by taking one of yours (http://ko.infragistics.com/community/forums/p/59382/301863.aspx#301863). It could be a solution for me but I have some troubles with it :
- The filters are not applied correctly,
- The ClearFilters button doesn't works,
- The empty data text appears some times,
- The select all checkbox behavior doesn't works.
What am I doing wrong ?