Normal 0 false false false EN-GB X-NONE X-NONE MicrosoftInternetExplorer4
Hi,
I have a WPF XamDataGrid where I want to use a custom usercontrol for one of the column cell editors. Values are enumerations.
Currently I have it working displaying text as below:
<igDP:FieldLayout.Fields>
<igDP:Field Name="Relation">
<igDP:Field.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}">
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamComboEditor}">
<Setter Property="ItemsProvider" Value="{StaticResource SpatialRelationKey}" />
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
</igDP:FieldLayout.Fields>
SpatialEnum is very similar to Anchor propery in WinForms. I want to be able to edit it in the same way you can set Anchor propery from within VisualStudio.
For that purpose I have created a user control with a 3x3 grid of ToggleButtons and one dependency property SpatialRelationProperty.
public static readonly DependencyProperty SpatialRelationProperty = DependencyProperty.Register("SpatialRelation", typeof(SpatialRelationEnum), typeof(AnchorUserControl), new PropertyMetadata(SpatialRelationChanged));
Please could you advise the best way/which XamDataGrid property I need to set so that my custom UserControl gets used as the editor for the “Relation” field?
Many thanks.
Hello Wurzel ,
I am looking into your requirements and I can suggest you add your user control in the EditTemplate property of the XamComboEditor that you have provided for Relation field. This way when your XamCmboEditor enters edit mode instead of empty textbox in your case will be shown your custom control.
If you need any additional assistance on this matter, or if I have misunderstood you in any way please let me know.
Hello Wurzel,
I am just checking have you been able to resolve your issue? If you still need any assistance on the matter do not hesitate to ask.
Thanks Elena,
Your suggestion worked:
<Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsProvider" Value="{StaticResource SpatialRelationKey}" /> <Setter Property="EditTemplate"> <Setter.Value> <ControlTemplate TargetType="{x:Type igEditors:XamComboEditor}"> <UserControls:AnchorUserControl SpatialRelation="{Binding DataItem.Relation, Mode=TwoWay}"></UserControls:AnchorUserControl> </ControlTemplate> </Setter.Value> </Setter></Style>
However, I still can’t achieve VisualStudio anchor like behaviour when it rolls down. My user control just sits within a cell and ignores its minimum height and width.As per the WinForms anchor control when in edit mode I would like to roll down and overlay neighbouring cells instead of being confined to the host grid cell.
Is this possible with WPF/Infragistics, or do I have to find a way to force resize of the grid cell to accommodate?
After some further investigation on this matter I believe that in your case may be more suitable if you change the appearance of the drop down only, so your user control can be able to overlap the cells below the current one. In order to achieve this you can copy the default XamComboEditor styles in your application and modify only the PART_Popup popup in the "ComboEditor_EditableComboBoxTemplate" by placing by your custom control in it. PART_Popup is internally used as dropdown. You can find our default templates for XamComboEditor on your computer in the file:
C:\Program Files (x86)\Infragistics\NetAdvantage 2011.2\WPF\DefaultStyles\Editors\EditorsGeneric.xaml
Please let me know if you have any further questions or concerns on this matter.
Hi Elena,I have tried a few approaches:1. Using entire xamComboEnditor style:<igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" EditorStyle="{StaticResource AnchorComboEditorComboBoxStyleKey}">Where style is defined:<Style x:Key="AnchorComboEditorComboBoxStyleKey" TargetType="{x:Type ComboBox}">But I can’t get this one working because original style is based on ComboBox so I end up with runtime error not being able to cast Combobox to EditorType2. Second option I have tried to use <Style TargetType="{x:Type igEditors:XamComboEditor}"> from within EditorsGeneric.xaml but this never calls my customized PART_Popup within ComboEditor_NonEditableComboBoxTemplate neither ComboEditor_EditableComboBoxTemplate.I have noticed this binding: igEditors:XamComboEditor.ComboEditor="{Binding RelativeSource={RelativeSource TemplatedParent}}"but I am not sure how to replace it or map it to my own custom one.3. Third option which worked best - I have replaced PART_Popup content in one of your templates “ComboEditor_EditableComboBoxTemplate” with my own user control. Below is how I have it linked:<Style.Triggers> <Trigger Property="IsEditable" Value="True"> <Setter Property="IsTabStop" Value="False" /> <Setter Property="Template" Value="{StaticResource ComboEditor_EditableComboBoxTemplate}" /> </Trigger> <Trigger Property="IsFocusWithin" Value="True"> <Setter Property="IsDropDownOpen" Value="True" /> </Trigger> <Trigger Property="IsFocusWithin" Value="False"> <Setter Property="IsDropDownOpen" Value="False" /> </Trigger></Style.Triggers>Problem here is focus scopes. When I change focus to different ContentPane or different app, the scope stays on popup (within its own focus scope) and the custom user control does not close.How does do drop down know it is supposed to close? Is there any event I can listen to?
Many thanks,Wurzel
I have been researching this issue further and I can suggest you have a look at the following forum thread:
http://community.infragistics.com/forums/p/26793/100153.aspx#100153
In it Alex provides a small sample application how you can change the default look of the dropdown on the XamComboEditor and place within in a custom control. Following the same approach you can place your own UserControl within the dropdown so it can be used instead of item list.
If you need any additional assistance on this matter, please do not hesitate to ask.