Is there any way to indent XamComboEditor I am facing the problem?
Please help me. If you didn't get the question i will descibe it again.
thanks in advance.
Hello,
You can create a style for the ComboBoxDataItem and bind to its value property with a DataTrigger and set the FontSize,FontWeight or Margin to indent.
Hope this helps.
Hello Alex,
Thanks For reply.
Sorry I didn’t get your point as I am binding ComboBox with a ObservableCollection.
I tell you in detail.................................
I am using a xamDatagrid and that grid is having one of the Cell as a xamComboEditor which is bound to DataContext.JobFunctionList.
JobFunctionList is coming from lookup Values which is combionation of two fields
1. RefGeneralValueId
2. RefGeneralValueDescLong
So ValuePath="RefGeneralValueId" and DisplayMemberPath="RefGeneralValueDescLong"
1. I have bound “Value” to PersonFunctionId(one of the field from another table). This may be one of the Id in RefGeneralValueId. As I want to show “RefGeneralValueDescLong” with respect to the PersonFunctionId at editing time so I have bound “Value” to PersonFunctionId.
Code for Datagrid :
<GroupBox Header="Job Function" Grid.Row="8" Grid.ColumnSpan="5" Margin="10">
<Controls1:LipperGrid Theme="Office2k7Silver" x:Name="grdContactAssociation" ScrollViewer.VerticalScrollBarVisibility="Auto" DataSource="{Binding ContactJobFunctionList}" ContextMenu="{StaticResource ContactAssociationMenu}" MinHeight="100" Margin="5" SelectedItemsChanged="grdContactAssociation_SelectedItemsChanged">
<DataPresenter:LipperGrid.FieldLayoutSettings>
<DataPresenter:FieldLayoutSettings AutoGenerateFields="False" />
</DataPresenter:XamDataGrid.FieldLayoutSettings>
<DataPresenter:XamDataGrid.FieldSettings>
<DataPresenter:FieldSettings LabelClickAction="Nothing" ></DataPresenter:FieldSettings>
</DataPresenter:XamDataGrid.FieldSettings>
<DataPresenter:XamDataGrid.FieldLayouts>
<DataPresenter:FieldLayout>
<DataPresenter:FieldLayout.Fields>
<DataPresenter:Field Name="PersonFunctionId" Label="Select Job Function" >
<DataPresenter:Field.Settings>
<DataPresenter:FieldSettings AllowEdit="True" AllowGroupBy="True" CellWidth="150" CellValuePresenterStyle="{StaticResource ComboJobFunction}"/>
</DataPresenter:Field.Settings>
</DataPresenter:Field>
<DataPresenter:Field Name="IsMain" Label="Primary Job Function" >
<DataPresenter:FieldSettings AllowEdit="False" AllowGroupBy="True" CellWidth="150" CellValuePresenterStyle="{StaticResource CheckBoxPrimaryJobFunction}"/>
</DataPresenter:FieldLayout.Fields>
</DataPresenter:FieldLayout>
</DataPresenter:XamDataGrid.FieldLayouts>
</DataPresenter:XamDataGrid>
</GroupBox>
2. I tried using DataTrigger like this
<Style x:Key="ComboJobFunction" TargetType="{x:Type DataPresenter:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataPresenter:CellValuePresenter}" >
<igEditors:XamComboEditor Margin="0" x:Name="cboJobFunction" Value="{Binding Path=DataItem.PersonFunctionId}"
ValuePath="RefGeneralValueId" DisplayMemberPath="RefGeneralValueDescLong"
ItemsSource="{Binding Path=DataContext.JobFunctionList, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
SelectedItemChanged="cboJobFunction_SelectedItemChanged" >
</igEditors:XamComboEditor >
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding Path=ComboBoxDataItem, RelativeSource={RelativeSource Self}, Value="-1" >
<Setter Property="Background" Value="Red"></Setter>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Might be I am missing something Please help me.
Hello,You can use this style in order for an item inside the ComboBox to appear indented, when its value is Name 1:
<Style TargetType="{x:Type ComboBoxItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Name}" Value="Name 1">
<Setter Property="Margin" Value="10,0,0,0"/>
</Style.Triggers>
Thankyou very much Alex,
It is Working fine. I changed the code like this
<DataTrigger Binding="{Binding Path=RefGeneralValueId}" Value="-1">
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontStyle" Value="Bold" />
<Setter Property="Foreground" Value="Gray"/>
when I changed the FontStyle to "Italic" it is working fine but when i Changed FontStyle to "Bold" I got two Error I don't know the reason
And
I Don't What did i do Wrong.
thanks
Amit mittal
Amit,
FontWeight property is the one you are looking for, not FontStyle.
Means to say this item should not get highlight in XamComboEditor.
Thanks Alex it is woking .
Is there any way so that when user do Mouse Over on this item User could not select this item only?