WPF DataGrid: Cancel the first row selection by default -
in datagrid first row becomes selected default. how can cancel this?
<window x:class="wpfapplication50.window7" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dg="clr-namespace:microsoft.windows.controls;assembly=wpftoolkit" title="window7" sizetocontent="widthandheight"> <window.resources> <!--data--> <xmldataprovider x:key="mydata" xpath="/info"> <x:xdata> <info xmlns=""> <item id="isbn 45-f1" name="winner" price="$32.05" author="aka" catalog="business"/> <item id="isbn 54-32" name="c++ inside" price="$10.00" author="john" catalog="language"/> <item id="isbn 14-a0" name="java inside" price="$9.00" author="tom" catalog="language"/> <item id="isbn 56-78" name="stock market" price="$8.50" author="bob" catalog="business"/> <item id="isbn aa-02" name="guideline health" price="$19.00" author="lee" catalog="health"/> <item id="isbn a4-07" name="c# inside" price="$8.50" author="bob" catalog="language"/> </info> </x:xdata> </xmldataprovider> <collectionviewsource x:key='src' source="{binding source={staticresource mydata}, xpath=item}"> <collectionviewsource.groupdescriptions> <propertygroupdescription propertyname="@catalog"/> </collectionviewsource.groupdescriptions> </collectionviewsource> <!--data--> </window.resources> <grid> <dg:datagrid autogeneratecolumns="false" background="white" isreadonly="true" padding="0" margin="0" borderthickness="0" gridlinesvisibility="none" horizontalscrollbarvisibility="disabled" headersvisibility="all" itemssource='{binding source={staticresource src}}' selectionmode="single" selectionunit="fullrow" verticalgridlinesbrush="darkgray" verticalscrollbarvisibility="disabled"> <dg:datagrid.columns> <dg:datagridtextcolumn binding="{binding xpath=@id}" header="id"/> <dg:datagridtextcolumn binding="{binding xpath=@name}" header="name"/> <dg:datagridtextcolumn binding="{binding xpath=@price}" header="price"/> <dg:datagridtextcolumn binding="{binding xpath=@id}" header="author"/> </dg:datagrid.columns> </dg:datagrid> </grid>
xaml: <dg:datagrid name="sc_dglist" canuseraddrows="false" loaded="sc_dglist_loaded">
cs:
private void sc_dglist_loaded(object sender, routedeventargs e) { sc_dglist.selectedindex = -1; }
Comments
Post a Comment