I want to define the listbox rows to start at 1, not the default 0. How do i do 开发者_StackOverflow中文版it ?
You dont. You basically learn to work within the context of the environment you use. WPF defines table positions in general to start at 0.
Feel free to program your own WPF replacement.
If you are determined to do it, I would make a method
private int ListIndex(int index){
return index - 1;
}
And then use ListIndex anywhere you index into the list, but as others pointed out, you really should shift your mindset to deal with 0 based indexes, as they are a standard in most programming situations.
This is really an issue of why or why not you should begin indices (of any kind, for that matter) from 0. See this post about the very topic. There are, arguably, some good reasons for starting an index from 0.
There are also some legacy technical reasons. For example, in C, the array was actually a pointer to the first element of the array, and the form array[i]
is equal to *(array + i)
, meaning that what the index really refers to is the offset from the first element of the array. Thus, a 0 offset references the first element, and 1 offset references the second element, and so on.
It's all about mathematical beauty.
In simple words, you can't
do that buddy.
精彩评论