我使用DevExpress。我有TreeListControl。一列包含具有多个值的组合框(由ComboBoxEditSettings实现)。当我在“组合框”中为父级设置一个值时,其子级将在更改焦点或按Enter键时更新,但不会立即更新。
以下是我已经尝试过的一些要点:
在ComboboxEdit中创建CustomButton并设置PopUpClose事件。在这 大小写绑定有效,但我尚未找到如何设置MyCustomButton OkButton事件。
这是我的守则的一部分。也许有助于理解我的情况。
<dxg:TreeListControl x:Name="Tree" ItemsSource="{Binding TreeItems, Mode=TwoWay}">
<dxg:TreeListControl.Columns>
<dxg:TreeListColumn FieldName="Node"/>
<dxg:TreeListColumn FieldName="Frequency"/>
<dxg:TreeListColumn.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding Samplers}" IsTextEditable="False" DisplayMember="SamplerLongText" ValueMember="SamplerId">
<dxe:ComboBoxEditSettings.StyleSettings>
<dxe:CheckedComboBoxStyleSettings/>
</dxe:ComboBoxEditSettings.StyleSettings>
</dxe:ComboBoxEditSettings>
</dxg:TreeListColumn.EditSettings>
</dxg:TreeListColumn>
</dxg:TreeListControl.Columns>
<dxg:TreeListControl.View>
<dxg:TreeListView
x:Name="TreeListView"
AllowPerPixelScrolling="True"
ShowTotalSummary="True"
KeyFieldName="TreeItemId"
ParentFieldName="ParentId"
ShowCheckboxes="true"
CheckBoxFieldName="IsChecked"
IsCheckBoxEnabledFieldName="IsEnable"
AllowRecursiveNodeChecking="True"
ShowNodeImages="True"
AutoWidth="True"
ImageFieldName="NodeImage"/>
</dxg:TreeListControl.View>
</dxg:TreeListControl>
提前谢谢!
答案 0 :(得分:0)
在使用CheckEdits时,我们有这个辅助类,用于完全相同的功能,但它也适用于您的ComboBoxEdits。 请注意,它利用了可能已经回答您问题的引擎盖下的EditValueChang ing 事件。
public partial class EditorCommitHelper
{
public static readonly DependencyProperty CommitOnValueChangedProperty = DependencyProperty.RegisterAttached("CommitOnValueChanged", typeof(bool), typeof(EditorCommitHelper), new PropertyMetadata(CommitOnValueChangedPropertyChanged));
public static void SetCommitOnValueChanged(GridColumn element, bool value)
{
element.SetValue(CommitOnValueChangedProperty, value);
}
public static bool GetCommitOnValueChanged(GridColumn element)
{
return (bool)element.GetValue(CommitOnValueChangedProperty);
}
private static void CommitOnValueChangedPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
{
GridColumn col = source as GridColumn;
if (col.View == null)
Dispatcher.CurrentDispatcher.BeginInvoke(new Action<GridColumn, bool>((column, subscribe) => {
ToggleCellValueChanging(column, subscribe);
}), col, (bool)e.NewValue);
else
ToggleCellValueChanging(col, (bool)e.NewValue);
}
private static void ToggleCellValueChanging(GridColumn col, bool subscribe)
{
TreeListView view = col.View as TreeListView;
if (view == null)
return;
if (subscribe)
view.CellValueChanging += new CellValueChangedEventHandler(view_CellValueChanging);
else
view.CellValueChanging -= view_CellValueChanging;
}
static void view_CellValueChanging(object sender, CellValueChangedEventArgs e)
{
TreeListView view = sender as TreeListView;
if ((bool)e.Column.GetValue(CommitOnValueChangedProperty))
view.PostEditor();
}
}
用法:
<dxg:GridColumn Header="your header"
FieldName="your_field"
your_xmlns:EditorCommitHelper.CommitOnValueChanged="True">
</dxg:GridColumn>