hi,
i have a xam data grid and i am adding field through code behind.there is a combo box in each column header(edited label presenter style).
how can i bind each column collection to its header combo box?..
my label presenter style is
<Style x:Key="HeaderWithCombo" TargetType="{x:Type igDP:LabelPresenter}"> <Setter Property="Padding" Value="5,4,5,4" /> <Setter Property="Background" Value="White"/> <Setter Property="LabelHighlight" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelHighlight}}" /> <Setter Property="InnerBorderBrush" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelInnerBorder}}" /> <Setter Property="OuterBorderBrush" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelOuterBorder}}" /> <Setter Property="Foreground" Value="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelForeground}}"/> <Setter Property="HorizontalContentAlignment" Value="Left" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:LabelPresenter}"> <ControlTemplate.Resources> <Storyboard x:Key="sbHighlightOff"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="highlight"> <SplineDoubleKeyFrame Value="0" KeyTime="00:00:00.25"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </ControlTemplate.Resources>
<Grid Background="White"> <Rectangle Stroke="{TemplateBinding OuterBorderBrush}" StrokeThickness="1" RadiusX="1.55015910897703" RadiusY="1.55015910897703" Fill="Transparent" Margin="0,0,0,0" x:Name="lineOuter" Width="Auto" Height="Auto" /> <Rectangle Stroke="{TemplateBinding InnerBorderBrush}" StrokeThickness="1" RadiusX="0.550159108977027" RadiusY="0.550159108977027" Fill="Transparent" Margin="1,1,1,1" x:Name="lineInner" Width="Auto" Height="Auto" /> <Grid Margin="{TemplateBinding Padding}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="sortIndicatorAndLabel"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <StackPanel Orientation="Horizontal" Grid.Column="0" >
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
<ContentPresenter HorizontalAlignment="Left" x:Name="LabelContent" Focusable="False" Content="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" VerticalAlignment="Center"/>
<igWindows:SortIndicator x:Name="SortIndicator" SortStatus="{TemplateBinding SortStatus}" Visibility="Collapsed" VerticalAlignment="Center" Width="Auto" HorizontalAlignment="Right"/> </StackPanel> <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
<Rectangle Width="1" Fill="Gray" Margin="2,2,0,2" ></Rectangle>
<ComboBox Style="{DynamicResource HeaderCombo}" HorizontalAlignment="Right" HorizontalContentAlignment="Right" Margin="1,0,0,0" Width="30" Background="Transparent" BorderBrush="{x:Null}">
<ComboBoxItem>Test -1</ComboBoxItem> <ComboBoxItem>Test -1</ComboBoxItem> <ComboBoxItem>Test -1</ComboBoxItem> <ComboBoxItem>Test -1</ComboBoxItem> <ComboBoxItem>Test -1</ComboBoxItem> <ComboBoxItem>Test -1</ComboBoxItem>
</ComboBox> </StackPanel> </StackPanel>
</Grid> </Grid>
<ControlTemplate.Triggers> <DataTrigger Binding="{Binding Path=Field.LabelTextAlignmentResolved, RelativeSource={RelativeSource Self}}" Value="Center"> <Setter Property="HorizontalAlignment" TargetName="sortIndicatorAndLabel" Value="Center"/> </DataTrigger> <!-- HighlightPrimary -->
<Trigger Property="HorizontalAlignment" Value="Center"> <Setter Property="VerticalAlignment" TargetName="SortIndicator" Value="Top"/> <Setter Property="HorizontalAlignment" TargetName="SortIndicator" Value="Center"/> <Setter Property="Margin" TargetName="SortIndicator" Value="0,5,0,0"/> </Trigger>
<!-- Only animate highlight --> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsMouseOver" Value="True"/> </MultiTrigger.Conditions> <MultiTrigger.EnterActions> </MultiTrigger.EnterActions> <MultiTrigger.ExitActions> </MultiTrigger.ExitActions> </MultiTrigger>
<Trigger Property="SortStatus" Value="Ascending"> <Setter TargetName="SortIndicator" Property="Visibility" Value="Visible" /> </Trigger> <Trigger Property="SortStatus" Value="Descending"> <Setter TargetName="SortIndicator" Property="Visibility" Value="Visible" /> </Trigger> </ControlTemplate.Triggers>
</ControlTemplate> </Setter.Value> </Setter> </Style>
thanks in advance....
Hello Jafar,
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
Since this is not a known issue, could you please send an isolated sample project, where this is reproduced, so I can investigate it further for you.
Looking forward for your reply.
thats work fine stefan,.
but there is a one issue when added command trigger for that combo ,iam getting an error message that "Items collection must be empty before using item source"
the modifited combobox is as follows.
<ComboBox x:Name="FilterCombo" HorizontalAlignment="Right" Style="{StaticResource HeaderCombo}" ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}, Mode=FindAncestor},Path=DataSource}" DisplayMemberPath="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:LabelPresenter},Mode=FindAncestor},Path=Field.BindingPath}" HorizontalContentAlignment="Right" Width="30" BorderBrush="{x:Null}">
<tp:EventCommandTrigger Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}, Mode=FindAncestor}, Path=Commands.SelectionChange }" Event="ComboBox.SelectionChanged" Parameter="{Binding ElementName=FilterCombo, Path=SelectedItem}"/> </ComboBox>
Note: iam adding columns to grid from code (View model)
I believe I have already answer your question in your other forum thread:
http://ko.infragistics.com/community/forums/t/80071.aspx
thanks stefan.this is what i exactly needed.
i have another doubt also,
i added xamdatagrid in xaml as follows
<igDP:XamDataGrid Grid.Row="0" x:Name="mygrid" DataSource="{Binding Model.TabularDeviceModelViews}" GroupByAreaLocation="None" ><!--FieldLayoutInitialized="XamDataGrid_FieldLayoutInitialized"--> <igDP:XamDataGrid.FieldLayoutSettings > <igDP:FieldLayoutSettings AutoGenerateFields="False" AutoArrangeCells="Never" FilterUIType="LabelIcons"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> <igDP:XamDataGrid.FieldSettings > <igDP:FieldSettings CellClickAction="SelectRecord" AllowEdit="False" FilterLabelIconDropDownType="Default"> </igDP:FieldSettings> </igDP:XamDataGrid.FieldSettings>
<tp:CommandTrigger.CommandTriggers>
<tp:EventCommandTrigger Command="{Binding Path=Commands.gridinit }" Event="igDP:XamDataGrid.FieldLayoutInitialized" Parameter="{Binding ElementName=mygrid}" /> </tp:CommandTrigger.CommandTriggers>
</igDP:XamDataGrid>
and iam adding colums dynamically from code. and grid displays filter icon like funnel with each column.
can i change that icon image and set our own icon ??
thanks...