February 10, 2011 Silverlight
February 10, 2011 Silverlight
Here is binding (I did not change it):
<UserControls:NumericTextBox AllowDecimals=”True”
Minimum=”0″ UseMinimum=”True”
Maximum=”999.999″ UseMaximum=”True”
MaxLength=”6″
Value=”{Binding Mileage, Mode=TwoWay}”
private double? _mileage;
public double? Mileage
{
get
{
return _mileage;
}
set
{
_mileage = value;
EnteredMileage = value;
RaisePropertyChanged("Mileage");
}
} _mileage = EnteredMileage.HasValue ? EnteredMileage : CalculatedMileage;
RaisePropertyChanged("Mileage");| Markdown | Result |
|---|---|
| *text* | text |
| **text** | text |
| ***text*** | text |
| `code` | code |
| ~~~ more code ~~~~ |
more code |
| [Link](https://www.example.com) | Link |
| * Listitem |
|
| > Quote | Quote |
In WPF there is MultiBinding support, I've seen some hacks fro Silverlight, but never worked with them, but you can take a look.
Also (if this piece is not performance constrained) consider using RaisePropertyChanged variant where you don't need to specify property name with magic string.
You solution should look like
RaisePropertyChanged(() => Mileage);
it will support refactorings nicely.
And last point.
_mileage = EnteredMileage.HasValue ? EnteredMileage : CalculatedMileage;
is equivalent to
_mileage = EnteredMileage ?? CalculatedMileage;
Happy coding! ;)
RaisePropertyChanged(() => Mileage);
Actually this is mobile, we trying to avoid performance hits.
And you are smart ass :)
Thanks
>> And you are smart ass :)
Is it good or bad? ;)
as for perfornance hit… If you don't change property thousands of time, I believe you won't notice any performance penalties…
You can look at the following article for some trivial tests: http://habrahabr.ru/blogs/net/95211/
I would say good in this case:)
Thanks for the link!