You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
3.8 KiB
103 lines
3.8 KiB
using System.Data;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
|
|
namespace SSWMS.Client
|
|
{
|
|
public partial class EditPanelDialog : Window
|
|
{
|
|
public EditPanelDialog()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void U_InitWindow(DataGrid dg, DataRow dr)
|
|
{
|
|
this.DataContext = dr;
|
|
int iRow = 0;
|
|
foreach (DataGridColumn dgc in dg.Columns)
|
|
{
|
|
this.gridControls.RowDefinitions.Add(new RowDefinition
|
|
{
|
|
Height = GridLength.Auto
|
|
});
|
|
TextBlock tbTitle = new TextBlock
|
|
{
|
|
MinWidth = 65,
|
|
Margin = new Thickness(5, 0, 2, 0),
|
|
VerticalAlignment = VerticalAlignment.Center,
|
|
Text = dgc.Header.ToString()
|
|
};
|
|
Grid.SetColumn(tbTitle, 0);
|
|
Grid.SetRow(tbTitle, iRow);
|
|
this.gridControls.Children.Add(tbTitle);
|
|
|
|
UIElement uieContent = null;
|
|
if (dgc is DataGridTextColumn)
|
|
{
|
|
Binding bind = (dgc as DataGridTextColumn).Binding as Binding;
|
|
TextBox tb = new TextBox
|
|
{
|
|
Width = 200,
|
|
Style = Application.Current.Resources["styleDefaultTextBox"] as Style,
|
|
Margin = new Thickness(10, 2, 5, 2),
|
|
IsEnabled = !dgc.IsReadOnly
|
|
};
|
|
tb.SetBinding(TextBox.TextProperty,
|
|
new Binding(string.Format("[{0}]", bind.Path.Path))
|
|
{
|
|
Converter = bind.Converter
|
|
});
|
|
uieContent = tb;
|
|
}
|
|
else if (dgc is DataGridCheckBoxColumn)
|
|
{
|
|
Binding bind = (dgc as DataGridCheckBoxColumn).Binding as Binding;
|
|
CheckBox cb = new CheckBox
|
|
{
|
|
Width = 200,
|
|
IsThreeState = false,
|
|
Margin = new Thickness(10, 2, 5, 2),
|
|
IsEnabled = !dgc.IsReadOnly
|
|
};
|
|
cb.SetBinding(CheckBox.IsCheckedProperty,
|
|
string.Format("[{0}]", bind.Path.Path));
|
|
uieContent = cb;
|
|
}
|
|
else if (dgc is DataGridComboBoxColumn)
|
|
{
|
|
DataGridComboBoxColumn dgcbc = dgc as DataGridComboBoxColumn;
|
|
ComboBox cb = new ComboBox
|
|
{
|
|
Width = 200,
|
|
Margin = new Thickness(10, 2, 5, 2),
|
|
DisplayMemberPath = dgcbc.DisplayMemberPath,
|
|
SelectedValuePath = dgcbc.SelectedValuePath,
|
|
ItemsSource = dgcbc.ItemsSource,
|
|
IsEnabled = !dgcbc.IsReadOnly
|
|
};
|
|
cb.SetBinding(ComboBox.SelectedValueProperty, string.Format("[{0}]",
|
|
(dgcbc.SelectedValueBinding as Binding).Path.Path));
|
|
uieContent = cb;
|
|
}
|
|
Grid.SetColumn(uieContent, 1);
|
|
Grid.SetRow(uieContent, iRow);
|
|
this.gridControls.Children.Add(uieContent);
|
|
++iRow;
|
|
}
|
|
}
|
|
|
|
private void WrapPanel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Button b = e.OriginalSource as Button;
|
|
switch (b.Name)
|
|
{
|
|
case "bOK":
|
|
this.DialogResult = true;
|
|
break;
|
|
}
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|