odd .net code need c# version
Eran Betzalel wrote a little extension class to DataGrid, everyone says that its great. But I cannot figure out what language it uses and how to make it work in Silverlight C#.net 3.5.
Heres the class he wrote 12 months ago:
public final class DataGridEx extends DataGrid{
public var maintainScrollAfterDataBind:Boolean = true;
public function DataGridEx()
{
super();
}
override public function set dataProvider(value:Object):void {
var lastVerticalScrollPosition:int = this.verticalScrollPosition;
var lastHorizontalScrollPosition:int = this.horizontalScrollPosition;
super.dataProvider = value;
if(maintainScrollAfterDataBind) {
this.开发者_开发百科verticalScrollPosition = lastVerticalScrollPosition;
this.horizontalScrollPosition = lastHorizontalScrollPosition;
}
}
It looks like to me that he has overridden a property, which as I see it is not possible in .net.
Thanks for all your remarks below I will add some further detail (very sorry for the delay in getting back to this, but Ive been in bed for 4 days hallucinating with a fever!).
I have a Silverlight Datagrid which is databound to a WCF service call, the grid has two buttons on each row of the grid, one to Open the station the other to Close the station, the rest of the data in the row is user information.
When the user presses the Open or Close button on a particular row, I am updating a summary section on the page at the top, as well as updating the data in the database; the grid needs refreshing at this point without the user losing focus on which row he/she clicked on.
The problem is that a refresh causes the first row to spring to the top of the visible area, I am really hoping is there a way of remembering the row position and moving the scroll bar via code?
There is a possibility that I might be able to update the data directly in the grid, but its complicated because although its open/closed there is other logic in there which makes it into a 4 state decision. However I could move that logic from the service into silverlight if that is my only option, although its not preferred.
Really really appreciate your help on this. Rich.
The langauge Eran Betzalel used is ActionScript. In this case, Eran is using it to enhance the datagrid provided by Flex, the SDK used to build rich internet applications based on Adobe Flash.
In contrast, Silverlight is a Microsoft framework for building internet applications. Silverlight applications are typically written in C# or VB.Net. Unfortunately, other than cosmetic similarity, there is no relationship between the Flex datagrid and the one in Silverlight, as they are published by different vendors.
This means that the implementations of the two datagrids will have nothing in common. As a result, the code you posted has no direct equivalent in Silverlight#.
It isn't clear from your question what you are trying to achieve. If you explain what you are trying to do, I am sure someone experienced in Silverlight will be able to help you.
You can set the browser scrollTo property via JavaScript, that way it scrolls back to the top of the table.
Edit:
Oops, no, you'll have to find a Silverlight way to do this.
Shouldn't be too hard however, just scroll to the table top.
I don't know about Silverlight, but in VB.NET, there's the (OnAfter)DataBind event which you could use.
Eran's code is Actionscript (an ECMAScript, like javascript), and extends an object within the Adobe Flex framework/api.
The code is compiled to a SWF, and will eventually be ran in Adobe Flashplayer.
Silverlight is Microsoft's response to Adobe Flash.
So, to summarise, what you've posted is not "odd .net code". It's not .net code. The OP from Eran isn't even tagged as .net code.
To "make it work" in Silverlight you'd probably have to write a compiler to compile ActionScript & Flex API to C#/Silverlight.
But that's not your question.
What is your question? What, exactly, are you trying to achieve in Silverlight?
精彩评论