0
XamDataGrid의 두 열에 XamComboEditor를 바인딩했습니다. XamComboEditor1에서 항목을 선택하면 특정 항목을 XamComboEditor2에 바인딩하고 싶습니다. SelectedItemChanged 이벤트를 XamComboEditor1에 연결했습니다. 이 이벤트는 항목을 선택할 때 논스톱으로 시작됩니다. 뒤에XamDataGrid에서 XamComboEditor SelectedItemChangedEvent 논스톱으로 실행
XAML-
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:igDP="http://infragistics.com/DataPresenter"
xmlns:igRibbon="http://infragistics.com/Ribbon"
xmlns:igOB="http://infragistics.com/OutlookBar"
xmlns:igDock="http://infragistics.com/DockManager"
xmlns:igTiles="http://infragistics.com/Tiles"
xmlns:igEditors="http://infragistics.com/Editors"
Title="Window1" Height="300" Width="720">
<Window.Resources>
</Window.Resources>
<Grid>
<DockPanel LastChildFill="True" Margin="0,26,0,-26">
<igDP:XamDataGrid x:Name="XamDataGrid1">
</igDP:XamDataGrid>
</DockPanel>
</Grid>
</Window>
코드 -
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Infragistics.Windows.DataPresenter;
using Infragistics.Windows.Editors;
namespace WpfApplication2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
EventManager.RegisterClassHandler(typeof(ValueEditor),
ValueEditor.ValueChangedEvent,
new RoutedPropertyChangedEventHandler<object>(OnValueChanged));
ComboBoxItemsProvider provider = new ComboBoxItemsProvider();
for (int i = 0; i < 6; i++)
provider.Items.Add(new ComboBoxDataItem(i, "Item " + i.ToString()));
FieldLayout fieldLayout = new FieldLayout();
UnboundField fld1 = new UnboundField();
fld1.Name = "Visibility Setting1";
Style style1 = new Style(typeof(XamComboEditor));
style1.Setters.Add(new Setter(XamComboEditor.ItemsProviderProperty, provider));
style1.Setters.Add(new EventSetter(XamComboEditor.SelectedItemChangedEvent, new RoutedPropertyChangedEventHandler<object>(XamComboEditor1_SelectedItemChanged)));
fld1.Settings.EditorStyle = style1;
fld1.Settings.EditorType = typeof(XamComboEditor);
fieldLayout.Fields.Add(fld1);
UnboundField fld2 = new UnboundField();
fld2.Name = "Visibility Setting2";
Style style2 = new Style(typeof(XamComboEditor));
fld2.Settings.EditorStyle = style2;
fld2.Settings.EditorType = typeof(XamComboEditor);
fieldLayout.Fields.Add(fld2);
this.XamDataGrid1.FieldLayouts.Add(fieldLayout);
this.XamDataGrid1.BindToSampleData = true;
}
void OnValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
if (sender is XamComboEditor || sender is XamCheckEditor || sender is XamDateTimeEditor)
{
(sender as ValueEditor).EndEditMode(true, true);
if (sender is XamComboEditor)
{
XamComboEditor comboEditor = (XamComboEditor)sender;
}
}
}
private void XamComboEditor1_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
// Create combo box items provider for freight modes
ComboBoxItemsProvider provider = new ComboBoxItemsProvider();
for (int i = 0; i < 10; ++i)
{
provider.Items.Add(new ComboBoxDataItem(i.ToString(), i.ToString()));
}
//// Get unbound field associated with index
Record record = this.XamDataGrid1.ActiveRecord;
// Get the combo editor with record
UnboundField uFld = (UnboundField)record.FieldLayout.Fields[1];
// Set style for uFld
Style style = new Style(typeof(XamComboEditor));
style.Setters.Add(new Setter(XamComboEditor.ItemsProviderProperty, provider));
style.Setters.Add(new Setter(XamComboEditor.DropDownResizeModeProperty, Infragistics.Windows.Controls.PopupResizeMode.None));
style.Setters.Add(new Setter(XamComboEditor.IsAlwaysInEditModeProperty, false));
style.Setters.Add(new EventSetter(XamComboEditor.SelectedItemChangedEvent, new RoutedPropertyChangedEventHandler<object>(XamComboEditor2_SelectedItemChanged)));
style.Setters.Add(new Setter(XamComboEditor.IsEditableProperty, false));
uFld.Settings.EditorStyle = style;
uFld.Settings.EditorType = typeof(XamComboEditor);
uFld.Settings.InvalidValueBehavior = InvalidValueBehavior.RetainValue;
uFld.Settings.AllowCellVirtualization = false;
e.Handled = true;
}
private void XamComboEditor2_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
}
}
}
친절하게 도움이됩니다. 몇 시간 동안이 문제에 갇혀 있습니다. – user977606
아무도. 도움 help – user977606
Infragistics guru (s)가 질문에 답합니다. 친절하게 도와주세요 – user977606