|
Does this have anything to do with Silverlight or WPF?
|
|
|
|
|
I thinks so,…It is a silverlight application that uses domainservies and RIA!!!!
In any case, it is always nicer to refrain making comments if there is no benefit to it. There are always nicer users willing to help.
|
|
|
|
|
picasso2 wrote: I thinks so So you don't actually know then? And the only technology you have mentioned in your question is ASPNET(sic) Web administrative tool.. Perhaps you should add more detail about the actual problem, and explain what it has to do with Silverlight or WPF.
|
|
|
|
|
Ok, so I have this code:
<pre>foreach (var item in getOriginalLoan)
{
if (index < getOriginalLoan.Count)
{
x1 = (getOriginalLoan[index - 1].paymentNumber * 670 / 360) + 70;
y1 = 700 - (getOriginalLoan[index - 1].endingBalance * 600 / getOriginalLoan[0].endingBalance);
x2 = (getOriginalLoan[index - 1].paymentNumber * 670 / 360) + 70;
y2 = 700 - (getOriginalLoan[index - 1].endingBalance * 600 / getOriginalLoan[0].endingBalance);
if (y2 <= 600)
{
graphCanvas.Children.Add(new Line
{
X1 = x1 + 1,
Y1 = y1 + 0,
X2 = x2 + 0,
Y2 = y2 + 0,
Stroke = Brushes.Red
});
}
index++;
}
}
Twice in my code. One draws a blue line (which works, exact same code but different collection), and this one draws a yellow line. However, as per my code, it WILL draw the line (although a dotted line, which as actually kind of a cool effect for what I'm going for), but only when I add the +1 to x1.
I have verified all my data is being read. Why is this happening? Thanks.
|
|
|
|
|
I have an xsd defined dataset which I use as the data class to send data back and forth between presentation layer and model/controller layer. For the same result, based on user selection of unit: U.S. v.s. Metric, I need to display differently. I am thinking to use xslt for the transformation, any suggestion? the software is an engineering calculator written in c# and used WPF. I have about 1000 data points in each calculation result, the original result is in U.S. units, if user select Metric, I need to flip to metric unit, but don't need to do the calculation again.
|
|
|
|
|
It really depends on how you want to display your data. Is it going to change frequently or are you just going to get it once and display it (switching backwards and forwards between the Metric/US version as appropriate). If it's just going to be a one off retrieval of the data and you don't need high resolution of your data, you could simply bind the data directly to the UI and use a value converter (a class that implements IValueConverter ) to convert the data to US units if necessary, or just return the raw data if it's Metric.
|
|
|
|
|
Thanks, Peter,
My dataset is in U.S unit, if user select Metric, I will capture metric input and converted to U.S. units and populate the dataset. The U.S. dataset is passed to model/controller to get the ouptput dataset also in U.S units, before display the result dataset back, if it is in Metric, I need to convert to metric. Currently the dataset is bound to WPF controls, directly e.g. <datagrid> and in U.S unit alone. I am going to look into ValueConverter.
|
|
|
|
|
If you convert them yourself, you'll need to convert all of them. You really only care about the ones the user is looking at. If you have 100,000 items and the user only looks at 100, there is no need to do the computations to convert the rest. The IValueConverter will accomplish this for you. It'll only call in to do the conversion on whats needed by the UI. Small optimization, but can make a huge difference in performance.
|
|
|
|
|
I have a ViewModel that contains a CompanyEntity. In the CompanyEntity is a property called IsActive. This property raises NotifyPropertyChanged. The property is bound to a checkbox in the UI.
What I'd like is to somehow execute a method in the VM when the user changes the IsActive property via the checkbox.
How do I do this?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
There's a couple of ways you could do this. One way is to hook into the property itself and call the method when you're changing the value. The other way is to use RX to observe the property and call the method whenever the property changes. There's a pretty decent primer here[^] that should give you a heads up.
|
|
|
|
|
Pete,
Can you explain what you mean by 'Hook into the property'?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
It's just a case of adding a piece of logic into your property setter and calling your method if the value has changed.
|
|
|
|
|
|
Well I implemented this and it doesn't work. I registered the property, compiled, and ran it. Nothing happens. The method I registered doesn't get called. The property IS changed, but the callback doesn't get called.
Too bad, it looked promising.
[UPDATE]
So here's what I just found....
I have a GridView bound to a list of JobAssignmentEntities and who's SelectedItem is bound to a property in my VM called SelectedJobAssignment.
In the CTOR of the VM I did
propertyObserver = new PropertyObserver<JobAssignmentHeaderEntity>(this.SelectedJobAssignment)
.RegisterHandler(n => n.PhaseStart, n => this.phaseStartChanged(n));
In order to register it the property must not be null, because of a null ref check in the register method.
So I moved the block above inside the SelectedJobAssignment's Getter and it works.
sooo, I will need to find a way to register EACH time the SelectedJobAssignment is set.
If it's not broken, fix it until it is
modified 11-Mar-14 11:59am.
|
|
|
|
|
Yes, this makes sense.
The PropertyObserver constructor attaches to the current value (this.SelectedJobAssignment ) of the passed property.
It does not automatically track if that property itself changes. (I.e., it doesn't notice if this.SelectedJobAssignment changes)
The registration tracks if the referenced property of that value changes. (I.e., it only notices if this.SelectedJobAssignment.PhaseStart changes)
|
|
|
|
|
Why not move it into the SelectedJobAssignment 's Setter ?
|
|
|
|
|
In ref to this and your prior posting....
I see how it works, it just looks kludgy.
First, I could see something like
propertyObserver.Register(typeof(theType), x => x.Property, MyHandler());
this way you can register multiple type, and only need to have this on one place.
Having to re-register each time the property changes is ugly
If it's not broken, fix it until it is
|
|
|
|
|
You just use a different property observer.
One for "the class" that checks when specific properties are changed.
In the handlers for that observers, you register handlers for the properties on the values of the "properties of the class".
This way the PropertyObserver handles the general case.
|
|
|
|
|
Ya I know. THe idea is great, just not the cleanest implementation.
If it's not broken, fix it until it is
|
|
|
|
|
Hi,
Simply you can achieve this by using triggers.
Write an Event Trigger with event name as Click and bind an ICommand property which is in the viewmodel.
So whenever there is a click on the checkbox(either select or deselect this method triggers)
Then you can write the logic according to your functionality.
There are so many ways to achieve this as well.
|
|
|
|
|
I'm trying to bind a window's Activated event to a command:
So I have:
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
and
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\AppResources.xaml"/>
</ResourceDictionary.MergedDictionaries>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Activated">
<i:InvokeCommandAction Command="{Binding WindowActivatedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ResourceDictionary>
</Window.Resources>
I get a compilation error
"Property 'Triggers' is not attachable to elements of type 'ResourceDictionary'"
What's wrong here??
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Move it outside the Window.Resources section. All you need do is add it after the opening Window tag.
|
|
|
|
|
Thanks Pete. That did it.
The Getter for the command fires, but the execute never does.
My code is pretty standard:
private ICommand _WindowActivatedCommand;
public ICommand WindowActivatedCommand
{
get
{
if (_WindowActivatedCommand == null)
_WindowActivatedCommand = new RelayCommand(p => windowActivated(), p => windowCanActivate());
return _WindowActivatedCommand;
}
}
private bool windowCanActivate()
{
return true;
}
private void windowActivated()
{
}
Neither windowCanActivate nor windowActivated ever fire. How do I know if the Event is calling the command?
If it's not broken, fix it until it is
|
|
|
|
|
How have you assigned your DataContext?
|
|
|
|
|
Yes.
If it's not broken, fix it until it is
|
|
|
|