My RadComboBox is always enabled in my DataForm even if I'm not in EditMode.
I try this w/o success :
1) Set by default IsEnabled="false" my RadComboBox
2) In the BeginningEdit event : ((RadComboBox)DataFormfiche.FindNameInContent("CategoriesComboBox")).IsEnabled = true;
3) In the EditEnding event : ((RadComboBox)DataFormfiche.FindNameInContent("CategoriesComboBox")).IsEnabled = false;
Always disabled!
5 Answers, 1 is accepted
Would you mine sharing your XAML and code-behind here so we can help you quicker? :)
Best regards,
Seree W.
A big thank you for your help Seree :
XAML File :
<
toolkit:DataForm Name="DataFormfiche" EditEnding="DataFormfiche_EditEnding" BeginningEdit="DataFormfiche_BeginningEdit" Background="Beige" Width="1024" CommandButtonsVisibility="Add, Cancel, Commit, Delete, Edit, Navigation" ItemsSource= "{Binding Data, ElementName=ficheDomainDataSource}" AutoGenerateFields="False" AutoCommit="False" AutoEdit="False" AddingNewItem="DataFormfiche_AddingNewItem" ContentLoaded="DataFormfiche_ContentLoaded" Loaded="DataFormfiche_Loaded" EditEnded="DataFormfiche_EditEnded">
...
<toolkit:DataField Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left">
<telerik:RadComboBox Name="NoCategorieComboBox" IsEnabled="False" SelectedValue="{Binding NoCategorieEspaceClos, Mode=TwoWay}" SelectedValuePath="NoCategorie" Width="240" Height="25" ItemsSource="{Binding Source={StaticResource categoriesespacesclosDomainDataSource}, Path=Data}" DisplayMemberPath="DescriptionCategorie_fr" />
</toolkit:DataField>
...
</DataTemplate>
</
toolkit:DataForm.EditTemplate>
</
toolkit:DataForm>
XAML.CS File
private void DataFormfiche_BeginningEdit(object sender, System.ComponentModel.CancelEventArgs e)
{
((
RadComboBox)DataFormfiche.FindNameInContent("NoCategorieComboBox")).IsEnabled = true;
}
private void DataFormfiche_EditEnding(object sender, DataFormEditEndingEventArgs e)
{
((
RadComboBox)DataFormfiche.FindNameInContent("NoCategorieComboBox")).IsEnabled = false;
}
Please try setting IsEnabled by using ContentLoaded instead of BeginningEdit/EditEnding.
void FormDetails_ContentLoaded(object sender, DataFormContentLoadEventArgs e) |
{ |
var lookup = (FormDetails.FindNameInContent("ComboLookup") as RadComboBox); |
if (e.Mode == DataFormMode.ReadOnly) |
{ |
lookup.IsEnabled = false; |
} |
else |
{ |
lookup.IsEnabled = true; |
} |
} |
Hope this help.
Best regards,
Seree W.
Thank you for your code. I try it and the code excute fine but the control stay in the same state (enabled).
The DataForm need to be refresh or something like this?
//var lookup = (DataFormficheespacesclos.FindNameInContent("ComboBoxQuantite") as RadComboBox);
if (e.Mode == DataFormMode.ReadOnly)
{
//lookup.IsEnabled = false;
((RadComboBox)DataFormficheespacesclos.FindNameInContent("NoCategorieEspaceClosComboBox")).IsEnabled = false;
}
else
{
((RadComboBox)DataFormficheespacesclos.FindNameInContent("NoCategorieEspaceClosComboBox")).IsEnabled = true;
//lookup.IsEnabled = true;
}
Have nice day.