I just spent four hours trying to understand why a colleague was having a problem with an Infragistics ComboBoxField. The problem is insignificant, but it's not in the nature of my Asperger's personality to say "I don't know".
If you bind the AllowEdit property of a ComboBoxField, changes to that property are not reflected in the UI until you mouse over the control.
Here's a short WPF C# .Framework project called ComboFieldBug that demonstrates the problem. It displays a XamDataGrid with two ComboBoxFields. The first has it's AllowEdit property bound and the second has its IsEnabled property bound.
Start by adding the required references.
<Window x:Class="ComboFieldBug.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:igDP="http://infragistics.com/DataPresenter"
xmlns:local="clr-namespace:ComboFieldBug"
mc:Ignorable="d"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<FrameworkElement x:Key="ProxyElement" DataContext="{Binding}"/>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ContentControl Visibility="Collapsed" Content="{StaticResource ProxyElement}"/>
<CheckBox IsChecked="{Binding IsComboEnabled}" Content="Enabled ComboBoxField"/>
<igDP:XamDataGrid Grid.Row="1" DataSource="{Binding Items}">
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
Label="AllowEdit" Name="Option1" IsEditable="False"
AllowEdit="{Binding DataContext.IsComboEnabled, Source={StaticResource ProxyElement}}"/>
<igDP:ComboBoxField ItemsSource="{Binding DataContext.Options, Source={StaticResource ProxyElement}}"
Label="IsEnabled" Name="Option2" IsEditable="False"
IsEnabled="{Binding DataContext.IsComboEnabled, Source={StaticResource ProxyElement}}"/>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
</Grid>
</Window>
and the code behind looks like this. There's nothing complicated here.
using System.Collections.ObjectModel;
using System.Runtime.CompilerServices;
using System.Windows;
public class cItem
{
public String Option1 { get; set; }
public partial class MainWindow : Window, INotifyPropertyChanged
private ObservableCollection<cItem> _Items = new ObservableCollection<cItem>()
new cItem() {Option1 = "Alpha", Option2 = "Beta"},
public ObservableCollection<cItem> Items
get { return _Items; }
get { return _Options; }
get { return _IsComboEnabled; }
InitializeComponent();
}
if (!Object.Equals(storage, value))
storage = value;
if (PropertyChanged != null)
}
}
When you mouse over the AllowEdit field, the dropdowns become visible. They should have become visible when AllowEdit was set to true.
No comments:
Post a Comment