i builds dynamic user control from observable collectibles
Cs code:
public static ObservableCollection<Model.Model.ControleData> ListControleMachine = new ObservableCollection<Model.Model.ControleData>();
public Genkai(string Autorisation)
{
InitializeComponent();
DataContext = this;
icTodoList.ItemsSource = ListControleMachine;
Model.Model.ControleData v = new Model.Model.ControleData();
v.ComputerName = "M57095";
v.ImportSource = "LOAD";
ListControleMachine.Add(v);
}
Xaml
<ItemsControl x:Name="icTodoList" ItemsSource="{Binding ListControleMachine}" >
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:ControlMachineII}">
<local:ControlMachineII />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
therefore, in my opinion, I have a usercontrole of type " local:ControlMachineII" associated with Model.Model.ControleData (), but how can I access ControleData from C # usercontrole code?
For example, let's say I want to remove usercontrole using the close button by itself, I need to at least access ControleData.ComputerName, and then remove it from Mainform.ListControleMachine.
cannot find the best practice to achieve this and play with my data in usercontrole code.
the delete button code looks the way I think (with a hard-coded value)
Genkai.ListControleMachine.Remove(Genkai.ListControleMachine.Where(X => X.ComputerName == "M57095").Single());