1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| using System.Windows;
using System.Windows.Controls;
namespace WpfTest
{
/// <summary>
/// Logique d'interaction pour WorkflowControl.xaml
/// </summary>
public partial class WorkflowControl : UserControl
{
public WorkflowControl()
{
InitializeComponent();
}
private void ShowScript(object sender, RoutedEventArgs e)
{
MessageBox.Show(((Button)sender).Tag.ToString());
}
private void dG2_Loaded(object sender, RoutedEventArgs e)
{
DataGrid dataGrid = sender as DataGrid;
if (dataGrid != null)
{
for (int i = 0; i < dataGrid.Items.Count; i++)
{
object toto = DataGridHelper.GetValue(dataGrid, i, 2);
Button b = UIChildFinder.GetChildOfType<Button>((DependencyObject)toto);
if (b != null)
{
mfStateAdmin script = dataGrid.Items[i] as mfStateAdmin;
if (script != null)
{
b.Tag = script.ActionRunVBScriptDefinition;
}
b.Click -= new RoutedEventHandler(ShowScript);
b.Click += new RoutedEventHandler(ShowScript);
}
}
}
}
}
} |