I want to insert an icon/image in the column header with the header text and want to write code on the icon OnClick event. For more clarification, I want to design my datagrid as shown in the image attached and the Icon is marked in the red box. Please assist for this.
Thanks Alex. It is working now. I had done something similar to what you did above at first, and it didn't work because of a workaround for another issue you gave me. It was to put in this code :
private void xdgField_FieldLayoutInitialized(object sender, FieldLayoutInitializedEventArgs e){ Style style = new Style(typeof(LabelPresenter)); EventSetter evSetter = new EventSetter(SizeChangedEvent, new SizeChangedEventHandler(labelSizeChanged)); style.Setters.Add(evSetter); e.FieldLayout.Fields[0].Settings.LabelPresenterStyle = style; e.FieldLayout.Fields[1].Settings.AllowResize = false;}
To be able to trap the resize event of the column. But it effectively stomps on any custom LabelPresenter style you've defined inline. We also have no window-spefic code behind since we are generated, and this cannot have EventSetters in the XAML. Is there a way to have custom LabelPresenter styles like above AND also catch the column resize event?
The style you are looking for is something like this:
<Style TargetType="{x:Type igDP:LabelPresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock VerticalAlignment="Top" Text="*" Foreground="Blue" />
<TextBlock Text="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
As I said, you can use the full default style in the DefaultStyles directory as a basis for your own.
Hope this helps.
I looked at that and it seems a bit daunting. What I'm trying to accomlish is to change the control template of just the content of the label to have be a stackpanel
<StackPanel Orientation="Horizontal"><TextBlock VerticalAlignment="Top" Text="*" Foreground="Blue" Visibility="Hidden"/><TextBlock Text="{TemplateBinding Content}" /></StackPanel>
such that I can bind the visibility of the initial blue "*" to a required property. Are there any examples of the most efficient way to accomplish this?
Hello,
There has been some changes in the LabelPresenter in 9.1 regarding the RecordFiltering and FieldFixing features. I suggest using the default xaml files that we ship in the DefaultStyles directory in the infragistics folder on your computer and using them as a basis for your own custom styles.
Josh -
Is this technique still valid for Infragistics WPF release 9.1? I try this exact sample, but nothing changes in my output of the XamDataGrid when it renders.