

That is best shown by posting code to us. Well see that is why we who try to help you "askers" need to see what kind of situation you are stuck at. I bet now you are gonna tell me you are not using any kind of ListBox, right? Visuals that represent data/item are usually called containers in WPF world. In WPF an item means the data while on the other side aĬontainer could be ListBoxItem or DataGridRow or ListViewItem.

If you didnt know my friend item has such general meaning that you almost always need to specify what you exactly mean. String sCellBorder_Name = "cellBorder_IDMaschine_" + maschine.Seriously this sentence " I have a control that colors values for the same item" sounds to me like you have a ListBoxĪnd ListBoxItems inside are being colored if item is lets say for sample "hello world" (you have 5 "hello world" in your data list of 10 items then those 5 will be colored). ConvertFromString(_sColor_Cell) ĬellBorder.Background = new SolidColorBrush (color) Grid_(btnMitarbeiter_Schicht) Ĭolor color = ( Color ) ColorConverter. Set_Position_of_Element_in_a_Grid(btnMitarbeiter_Schicht, rowNr, iColNr) PreviewMouseLeftButtonDown += new MouseButtonEventHandler (Start_ Drag_Event) ConvertFromString(sColor_SchichtGruppe)) ītnMitarbeiter_Schicht.Content = mitarbeiter.Nachname ītnMitarbeiter_Schicht.Name = "button_IDMitarbeiter_" + mitarbeiter.IDMitarbeiter ītnMitarbeiter_Schicht. erstelle_Schichtplan_Eintrag(IDMaschine, IDSchicht, IDMitarbeiter, DatePlan, PosNrBesetzung) Ĭhild_Button.Background = new SolidColorBrush (color) Ĭode to create a button during the runtime.īutton btnMitarbeiter_Schicht = new Button () ītnMitarbeiter_Schicht.Background = new SolidColorBrush (( Color ) ColorConverter. get_Key_Value_from_String_as_Date(sPanelName, "DatePlan" ) ĬlsSchichtplan. get_Key_Value_from_String_as_Integer(sPanelName, "PosNrBesetzung" ) ĭateTime DatePlan = clsStrings. get_Key_Value_from_String_as_Integer(sPanelName, "IDSchicht" ) get_Key_Value_from_String_as_Integer(sPanelName , "IDMaschine" ) Private void Target_Border_Drop( object sender, DragEventArgs e)īorder target_Control = ( Border )sender get_Key_Value_from_String_as_Integer(sControlname, "IDMitarbeiter" ) String sName = ( string ) button.Content Private void Start_Drag_Event( object sender, MouseButtonEventArgs e) Int IDMitarbeiter = ( int ) e.Data.GetData( "IDMitarbeiter" ) String sName = ( String )e.Data.GetData( "Name" ) String sColor = ( String )e.Data.GetData( "Farbe" ) Ĭolor color = ( Color ) ColorConverter. Move) Įvent, the DragObject is read out directly DoDragDrop(button, dataObj, DragDropEffects. *set informations to the dragged objectĭataObj.SetData( "IDMitarbeiter" , IDMitarbeiter) ĭragDrop. Of the Drag-Operation is then created a DragObject and this object is then Drop += new DragEventHandler (Target_ Border_Drop) That is on eIn drag process should rule then needs the property. PreviewMouseLeftButtonDown += new MouseButtonEventHandler ( Start_Drag_Event) PreviewMouseLeftButtonDown EventĪdded as an event in Xaml or as here at runtime as here to an event methodītnMitarbeiter_Schicht. Operation, any data can be transmitted at runtime.Ĭreate a drag process, all freely definable information is placed in aĭefined information can then be read out by the drag object at the target as inīutton element to be pulled requires one. C # Code example shows the simple creation of a drag and drop function in WPFĮxample, a rectangular planning field (WPF button) is drawn into a planning
