c# - WPF TabControl no selected Item on start -


i using wpf tabcontrol display items bound viewmodel.

by default on start first item of list selected want no item selected on start. can set selecteditem in onselectionchanged event null no item selected on start no longer possible manually select item.

public partial class projectscopemain : window {   private bool firststart = true;    public projectscopemain()   {     this.initialized += this.projectscopemain_initialized;     this.initializecomponent();   }    private void projectscopemain_initialized(object sender, system.eventargs e)   {     this.tabcontrolsettings.selectionchanged += tabcontrolsettingsonselectionchanged;   }    private void tabcontrolsettingsonselectionchanged(object sender, eventargs e)   {       this.tabcontrolsettings.selecteditem = null;   }    private void buttoncreate_click(object sender, system.windows.routedeventargs e)   {     this.close();   } } 

my xaml code. selectedindex=-1 not work

        <customcontrols:tabcontrol x:uid="tabcontrolsettings" x:name="tabcontrolsettings"                                     prism:regionmanager.regionname="{x:static infrastructure:regionnames.projectscopetabsregion}"                                     tabstripplacement="left" style="{dynamicresource tabcontrolstyle}"                                      itemcontainerstyle="{dynamicresource tabitemverticalprojectscopestyle}" selectedindex="-1"/> 

i don't believe tab control lets have nothing selected. easy work around create empty tab collapsed visibility, , navigate when otherwise wish clear tab control. result in tab's content being shown (which in case empty) , no header being present.

<tabcontrol name="mytabcontrol" selectedindex="0">     <tabitem header="" visibility="collapsed">         <!--there's nothing here-->     </tabitem>     <tabitem header="item 1">         <textblock text="some item 1" />     </tabitem>     <tabitem header="item 2">         <textblock text="some item 2" />     </tabitem> </tabcontrol> 

you 'clear' with:

mytabcontrol.selectedindex = 0; 

since wish bind child items, imagine need combine children in resource first.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -