Recently, Silverlight 5 beta was released. As a developer focusing on Silverlight, I am still very happy. At least it proves that Sl is still being improved and still developing.
This post is mainly used to solve the common problems in datagrid development:
When scrollview appears in the DataGrid, if you drag it, you will find that the checkbox and expander in the DataGrid will be disordered.
You can effectively solve this problem by adding a datagridrowspresenter to the scrollview in the template of the DataGrid:
<Scrollviewer >
<SDK: datagridrowspresenter X: Name= "Rowspresenter" />
</Scrollviewer>
DetailsCodeIt will not be pasted,: datagridscrollview.rar
Remove the DataGrid style and test it.
In actual situations, we may need to process records when the value is 0. Here we provide a method
here, the template of the DataGrid is modified, and The xaml of the datagridrowspresenter section is found.
<SDK: datagridrowspresenter X: Name= "Rowspresenter" Grid.Columnspan= "2" Grid.Row= "1" />
Replace it:
<Grid Grid.Columnspan= "2" Grid.Row= "1" >
<SDK: datagridrowspresenter X: Name= "Rowspresenter"/>
<Textblock Text= "No related records"
Visibility= "{Binding elementname = rowspresenter, Path = children. Count, converter = {staticresource norecordsconverter }}"
Horizontalalignment= "Center" Verticalalignment= "Center" Fontsize= "12"/>
</Grid>
We can see that it is binding the children attribute of the datagridrowspresenter object.
Code of the value converter section:
Public ObjectConvert (Object Value, Type targettype,ObjectParameter, cultureinfo Culture)
{
Return Value. Tostring () ="0"? Visibility. Visible: visibility. collapsed;
}
Public ObjectConvertback (Object Value, Type targettype,ObjectParameter, cultureinfo Culture)
{
Return Null;
}
This article is written here. I hope these two useful skills will help you with your ideas.