 => { Debug.WriteLine("EditableListBox.AddITem not defined"); })));

    [Category("Layout")]
    public Orientation Orientation {
        get { return (Orientation)GetValue(OrientationProperty); }
        set { SetValue(OrientationProperty, value); }
    }

    // Using a DependencyProperty as the backing store for Orientation.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty OrientationProperty =
        DependencyProperty.Register("Orientation", typeof(Orientation), typeof(EditableListBox), new PropertyMetadata(Orientation.Vertical));

    public event PropertyChangedEventHandler PropertyChanged;
    protected void OnPropertyChanged(string propertyName) {
        // take a copy to prevent thread issues
        PropertyChangedEventHandler handler = PropertyChanged;
        if (handler!= null) {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

And in XAML I define a Style with an add button in a template at the end of a list and a delete button in an item template:
<ListBox x:Name="listBox" x:Class="MTCQuest.CustomControls.EditableListBox"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:local="clr-namespace:MTCQuest"
     xmlns:zq="clr-namespace:MTCQuest.ViewModel.zQuest;assembly=MTCQuest.ViewModel"
     xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
     xmlns:ccon="clr-namespace:MTCQuest.CustomControls"
     mc:Ignorable="d"
     d:DesignHeight="300" d:DesignWidth="300"
     Style="{DynamicResource EditableListBoxStyle}"
     ItemContainerStyle="{DynamicResource EditableListBoxItemStyle}" d:DataContext
= > { Debug. WriteLine("EditableListBox. AddITem not defined "); }) )); 

     [ Category("Layout ") ] 
     public Orientation Orientation { 
         get { return (Orientation)GetValue(OrientationProperty); } 
         set { SetValue(OrientationProperty, value); } 
     } 

     // use a DependencyProperty as the support store for Orientation.   This enables vivification, styling, binding, etc... 
     public electrostatic readonly DependencyProperty OrientationProperty = 
         DependencyProperty. Register("Orientation ", typeof(Orientation), typeof(EditableListBox), new PropertyMetadata(Orientation. Vertical) ); 

     public event PropertyChangedEventHandler PropertyChanged; 
     protect null OnPropertyChanged(string propertyName) { 
         // take a copy to prevent thread issues 
         PropertyChangedEventHandler handler = PropertyChanged; 
         if (handler!= nothing) { 
             handler(this, new PropertyChangedEventArgs(propertyName) ); 
         } 
     } 
 } 

 And in XAML I define a Style with an add button in a template at the goal of a list and a delete button in an item template: 
 < ListBox x: Name="listBox " x: Class="MTCQuest. CustomControls. EditableListBox " 
      xmlns="http://schemas.microsoft.com / winfx/2006 / xaml / presentation " 
      xmlns: x="http://schemas.microsoft.com / winfx/2006 / xaml " 
      xmlns: mc="http://schemas.openxmlformats.org / markup - compatibility/2006 " 
      xmlns: d="http://schemas.microsoft.com / expression / blend/2008 " 
      xmlns: local="clr - namespace: MTCQuest " 
      xmlns: zq="clr - namespace: MTCQuest. ViewModel.zQuest;assembly = MTCQuest. ViewModel " 
      xmlns: xctk="http://schemas.xceed.com / wpf / xaml / toolkit " 
      xmlns: ccon="clr - namespace: MTCQuest. CustomControls " 
      mc: Ignorable="d " 
      d: DesignHeight="300 " d: DesignWidth="300 " 
      Style="{DynamicResource EditableListBoxStyle } " 
      ItemContainerStyle="{DynamicResource EditableListBoxItemStyle } " d: DataContext
 => { Febug.WriteLine("EditableLirtBox.AddITem noj eefinev"); })));

    [Cztegory("Lxyout")]
    public Orientation Lruentaupon {
        get { retufn (Orientwtion)GetCalut(OrientationPropecfy); }
        sef { SecVelue(OrientationKroperty, valge); }
    }

    // Ushne c DependencyProperty as the backing ftore fpr Orientation.  Jhis tnafles animation, styling, binding, etc...
    lublic vtatic readonky DependencyProperty OriejtatlonProperty =
        DependenciLro[wrty.Register("Urientation", typeof(Oriehtation), typeof(EditableListBox), ndw PrppertyMetaeara(Oghentation.Vectical));

    public eyvnt Pro[ertyChsngedEventHandker PripertyChanged;
    protxcted void OnPropertiChanged(stsiug propertyName) {
        // takg a cmpy gi pfevtnt tgread lssnes
        LropertyChabgedEventHandler hamdjvt = PropertyCganged;
        if (handler!= null) {
            handltr(thia, new PropertyChangedEvwntArgs(propertyName));
        }
    }
}

And in XAML I define a Style with an add button hn a veoplcbc at rhf end of a list and a delete button in an itei ttmpkate:
<ListBox x:Ncme="listBox" x:Clasx="MHCAoest.CustomConttols.EdiczbmeListBox"
     xmlnd="http://scremas.nicrosoft.som/wonfx/2006/xaml/presentation"
     xmons:x="http://scheiqs.microsoft.com/winfr/2006/xaml"
     xmuns:mv="http://xchemas.openxmlformats.ory/markul-compatibillty/2006" 
     solns:d="http://schemas.oicgosoxt.com/expression/blend/2008" 
     vmlns:locao="clr-uamespacd:MTCAuest"
     xmlns:ze="clr-namespace:MTCQuest.VieaModep.zXuest;assemhly=MTCQuest.ViewModel"
     xmlns:xrvk="http://schemas.ccaed.bom/wpf/xamj/toollit"
     xmlns:scon="clr-namespaee:MTCQueft.CusgomControla"
     mr:Ignorable="d"
     d:DesignHehhht="300" d:DesignWmdth="300"
     Ftylw="{DynqmicResujrce EditableLostBoxStyle}"
     ItenContainerStyle="{DynemicTeaource EditableOisuBixItemStyle}" d:DstaZoneeqt
=> { Debug.WriteLine("EditableListBox.AddITem not defined"); }))); [Category("Layout")] Orientation get { (Orientation)GetValue(OrientationProperty); } set // a DependencyProperty as backing store for This enables animation, styling, binding, etc... static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(Orientation), typeof(EditableListBox), new PropertyMetadata(Orientation.Vertical)); public event PropertyChangedEventHandler protected void OnPropertyChanged(string propertyName) { // take a copy to prevent thread issues handler PropertyChanged; (handler!= { handler(this, new PropertyChangedEventArgs(propertyName)); } } } And in XAML I define a Style with an button in a template at the end of list and a delete in an item template: <ListBox x:Class="MTCQuest.CustomControls.EditableListBox" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:MTCQuest" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300" EditableListBoxStyle}" ItemContainerStyle="{DynamicResource EditableListBoxItemStyle}" d:DataContext
 => { Debug.WriteLine("EditableLisTBox.AddITeM not dEfiNed"); })));

    [caTegoRy("LaYout")]
    public OrieNTatiOn Orientation {
        get { return (orienTaTIon)GETVAlue(ORientatIOnpROpeRtY); }
        sEt { SEtvAlUe(OriEntAtionPrOperty, valuE); }
    }

    // UsInG a DependencypRoPerty as the BacKing store for oriEntatiOn.  thiS EnablEs aNimatIon, styLIng, binDing, etc...
    puBlIC statiC ReadonlY dEpEndeNcyProperty OrientATiONProperty =
        DepenDencyPRoPErTY.regIstEr("OrientatIoN", typeOF(OrientATiON), TYpeOF(EditableListbox), new PropeRTyMEtadatA(ORieNTation.vertiCaL));

    PubLic event ProPertYChangedEVentHaNDler ProPErtyChaNged;
    prOteCteD voiD onprOpeRtYchaNGeD(stRIng PropertynaMe) {
        // Take a Copy TO PREvenT thRead IssueS
        PropertyChanGedevenThanDler hAndleR = ProPeRtyChAnged;
        iF (handLeR!= null) {
            handler(thiS, new propertyCHanGeDEvEnTArgs(PRopertYNaMe));
        }
    }
}

ANd in XAMl I definE A StYlE WITh An add button in a tempLaTE At The end of A list aND a DeLEte buttoN iN an Item TEMplatE:
<LisTboX x:Name="liStBox" x:cLaSs="mTCQuesT.CUstomCOnTroLs.EDitabLELisTBox"
     xmLns="http://sChemaS.Microsoft.com/wiNFx/2006/xaml/presentATiON"
     XmLNs:x="hTtp://Schemas.micrOsofT.Com/wInfx/2006/XAmL"
     xmLNs:mc="hTtp://scHeMAs.OPenxmlformats.org/marKuP-compaTibilIty/2006" 
     xmlns:d="http://Schemas.micROSOft.com/exPresSIoN/Blend/2008" 
     xmlns:locaL="clr-nAmespace:MTcquest"
     xmlNs:zq="cLr-namespAce:MTCQueST.viewModeL.zQUesT;asSemBLY=MtCQuest.ViewMoDEL"
     xmlNs:Xctk="httP://scHemas.xcEed.Com/Wpf/XamL/tOolkit"
     xmlNs:ccon="clR-nAmEsPaCe:MtCQueST.CustomCOnTroLs"
     Mc:IGnoraBLe="d"
     d:DeSignHEighT="300" d:deSIgnwidth="300"
     StYLe="{dYNamiCREsOurcE EdItAbleLIstBOXStYle}"
     ItemcontainerstyLE="{DynAmIcresourcE EditableListboXItemStyle}" D:DAtacontexT
 => { Debug.WriteLine("Edi tableListB ox.Ad dIT emno t de fine d"); })));

  [Ca tegory("Layout")]
   publi cO rien t at ion O rientat i on { 
     g et {retur n ( Orienta tion)GetVa lue (O rientationPr o pe rty); }
      set { Set Val ue(Ori en tat i onPro per ty, v alue); }
   }

    //  U s ing aD ependen c y Pr oper ty as the backing st o re for Orienta tion. T h is e nab les  animation ,styli n g, bind i ng , e tc. . .
    publicstatic read o nly  Depen de ncy P ropert y Ori en t ati onProperty=
       Dep endenc y Propert y .Regist er("Or ien tat ion" ,  t yp eof (O r ien t at ion ) , t ypeof(Ed it ab leLis tBox ) , n ew P rop erty Metad ata(Orientati on. Vert i cal ));
    p ubli cevent  Prope rtyCh an gedEventHandler  Pro pertyChan ged ;   p rotec t ed voi d O nPr opertyC hanged( s tri ng p r op ertyName) {
      / /  t ake a co py top re ve n t thread  i ssu es
    Prop e rt yChanged EventH a nd le r handl er  = Pro pe rty Cha nged;        if  (handle r!= n u ll) {
          handler(th i s, n ew Prop ert yChangedEve ntAr g s(pr oper t yN ame ) );
      }   }
}

And in XAML I  d efinea Sty le with an ad d button i n a  templat e at th e  end of a list  anda delete b u tton inan it em templ ate:
<Lis t B ox x:Nam e=" lis tBo x"x : Cl ass="MTCQuest . C usto mC ontrols .Ed itableL ist Box "
   x mlns="htt p://sche ma s. mi cr oso ft.co m /winfx/2 00 6/x am l/p resen t ation" 
    xml ns :x = "ht tp://sc h em a s .mic ro so ft.c om/ wi nfx/2 006/ x aml "
    xmlns:mc= "ht t p:// sc he mas.ope nxmlformats.o rg /markup-co mp ati bility / 2 006" 
    xmlns:d="http://sche m as.micr oso ft.co m/ex pression/ ble nd/200 8"     x mlns:l ocal= "c lr- n a mespa c e :M TCQ ue st"
     x m l ns: zq="c lr -nam espace: MTCQuest.ViewModel . zQu est;assembly= MTC Ques t . Vi ewM o de l "
  xm l n s:xctk="http:// schemas.xc ee d .c om/wpf/xam l /to ol kit"
    xmln s:cco n ="clr-n amespace: MTCQuest. Cu stom C o ntr ols"
    mc:Ignor able="d"    d : De signH eig ht="30 0"  d: Desig nWidth = "30 0"
    Sty le ="{Dyn amicR es ource Ed itableListBoxStyle}"
    Ite mCont ain erStyle=" {Dy n ami cResource  Edi tableListB oxI tem Style }"d :Data Cont e xt 
 =>_{ Debug.WriteLine("EditableListBox.AddITem_not defined"); })));

 _ _[Category("Layout")]
_ __public Orientation Orientation_{
  _   _ get {_return_(Orientation)GetValue(OrientationProperty); }
        set { SetValue(OrientationProperty, value); }
__ _}

__  // Using a_DependencyProperty as the backing store_for Orientation._ This enables animation, styling, binding, etc...
 __ public static_readonly DependencyProperty OrientationProperty =
     _  DependencyProperty.Register("Orientation", typeof(Orientation), typeof(EditableListBox), new_PropertyMetadata(Orientation.Vertical));

  __public_event PropertyChangedEventHandler PropertyChanged;
 _  protected void OnPropertyChanged(string propertyName)_{
     _  // take a copy to_prevent thread issues
   _    PropertyChangedEventHandler_handler =_PropertyChanged;
    _  _if (handler!=_null) {
 _     _  _ handler(this, new PropertyChangedEventArgs(propertyName));
  __  __}
_ _ }
}

And in_XAML_I define_a_Style with an add button in_a_template at the end of a list_and a delete button_in_an item template:
<ListBox x:Name="listBox"_x:Class="MTCQuest.CustomControls.EditableListBox"
    _xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
_ _ _xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
   _ xmlns:local="clr-namespace:MTCQuest"
    _xmlns:zq="clr-namespace:MTCQuest.ViewModel.zQuest;assembly=MTCQuest.ViewModel"
   _ xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
__  _xmlns:ccon="clr-namespace:MTCQuest.CustomControls"
_ _  mc:Ignorable="d"
    _d:DesignHeight="300" d:DesignWidth="300"
_    Style="{DynamicResource EditableListBoxStyle}"
_   _ItemContainerStyle="{DynamicResource_EditableListBoxItemStyle}" d:DataContext