Scaling woes
-
Ok, that makes sense too. When I run (or indeed the designer does the same). I've now got an exception being fired by the WidthScaler
if ( values.Length != 2 ||
values[0].GetType() != typeof(double) ||
values[1].GetType() != typeof(double) )
{
throw new NotSupportedException("Source values should be a pair of doubles");
}The debugger shows that the first value, Duration, is correct. But the second, is
DependancyProperty.UnsetValue
. If I remove the throwing of an exception and return null, the WidthScaler (the IMultiValueConverter) doesn't seem to be called again!Regards, Ray
Sorry, your second binding is incorrect also. You have:
<Binding ElementName="scale" Path="ScalingFactor"/>
But "scale" is not a named element, it is a resource. To access it, you need to set the Binding.Source property like so:
<Binding Source="{StaticResource scale}" Path="ScalingFactor"/>
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com
-
Sorry, your second binding is incorrect also. You have:
<Binding ElementName="scale" Path="ScalingFactor"/>
But "scale" is not a named element, it is a resource. To access it, you need to set the Binding.Source property like so:
<Binding Source="{StaticResource scale}" Path="ScalingFactor"/>
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com
-
Great! The application now runs, but moving the slider doesn't seem to result in the MultiBinding being called again (break-pointing doesn't stop the code).
Regards, Ray
Did you update the binding there as well? It has the same problem as before. Make sure to look at the Output window of Visual Studio, that will have any binding errors listed. Also, make sure the Binding for the slider has Mode=TwoWay.
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com
-
Did you update the binding there as well? It has the same problem as before. Make sure to look at the Output window of Visual Studio, that will have any binding errors listed. Also, make sure the Binding for the slider has Mode=TwoWay.
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com
I've now got this, but it still doesn't look like it works: Xaml is now:
<Slider x:Name="scaleSlider" Width="100" Minimum="0.5" Maximum="10.0" Value="{Binding Source=scale, Path=ScalingFactor, Mode=TwoWay}"/>
I'd changed the binding in the MultiBinding to:
<Binding Source="{StaticResource scale}" Path="ScalingFactor"/>
Error in Output window is: System.Windows.Data Error: 35 : BindingExpression path error: 'ScalingFactor' property not found on 'object' ''String' (HashCode=-528916476)'. BindingExpression:Path=ScalingFactor; DataItem='String' (HashCode=-528916476); target element is 'Slider' (Name='scaleSlider'); target property is 'Value' (type 'Double') I'm sure the error will help, once I understand it! ;-)
Regards, Ray
-
I've now got this, but it still doesn't look like it works: Xaml is now:
<Slider x:Name="scaleSlider" Width="100" Minimum="0.5" Maximum="10.0" Value="{Binding Source=scale, Path=ScalingFactor, Mode=TwoWay}"/>
I'd changed the binding in the MultiBinding to:
<Binding Source="{StaticResource scale}" Path="ScalingFactor"/>
Error in Output window is: System.Windows.Data Error: 35 : BindingExpression path error: 'ScalingFactor' property not found on 'object' ''String' (HashCode=-528916476)'. BindingExpression:Path=ScalingFactor; DataItem='String' (HashCode=-528916476); target element is 'Slider' (Name='scaleSlider'); target property is 'Value' (type 'Double') I'm sure the error will help, once I understand it! ;-)
Regards, Ray
The two bindings you just posted are not the same. Compare them carefully (ignoring the fact that Mode is set on one of them though).
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com
-
The two bindings you just posted are not the same. Compare them carefully (ignoring the fact that Mode is set on one of them though).
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com
Ok, given that they're both working on a source of "scale" and a Path of ScalingFactor (ignoring Mode), that leaves the fact that the second isn't a StaticResource. I'm not certain how to convert between the two markup conventions (although I guess I could expand out the Slider's "Value" element). I tried this and it doesn't change anything :-(
<Slider x:Name="scaleSlider" Width="100" Minimum="0.5" Maximum="10.0" Value="{Binding Source={StaticResource scale}, Path=ScalingFactor, Mode=TwoWay}"/>
Regards, Ray
-
Ok, given that they're both working on a source of "scale" and a Path of ScalingFactor (ignoring Mode), that leaves the fact that the second isn't a StaticResource. I'm not certain how to convert between the two markup conventions (although I guess I could expand out the Slider's "Value" element). I tried this and it doesn't change anything :-(
<Slider x:Name="scaleSlider" Width="100" Minimum="0.5" Maximum="10.0" Value="{Binding Source={StaticResource scale}, Path=ScalingFactor, Mode=TwoWay}"/>
Regards, Ray
You still get the same binding error with that change?
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com
-
Ok, given that they're both working on a source of "scale" and a Path of ScalingFactor (ignoring Mode), that leaves the fact that the second isn't a StaticResource. I'm not certain how to convert between the two markup conventions (although I guess I could expand out the Slider's "Value" element). I tried this and it doesn't change anything :-(
<Slider x:Name="scaleSlider" Width="100" Minimum="0.5" Maximum="10.0" Value="{Binding Source={StaticResource scale}, Path=ScalingFactor, Mode=TwoWay}"/>
Regards, Ray
Sorry, I noticed that you did not implement INotifyPropertyChanged correct. The parameter being passed needs to be the name of the property that changed, not some random text. Otherwise the system will never know where to look for the changed.
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com
-
Sorry, I noticed that you did not implement INotifyPropertyChanged correct. The parameter being passed needs to be the name of the property that changed, not some random text. Otherwise the system will never know where to look for the changed.
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com
-
Sorry, I noticed that you did not implement INotifyPropertyChanged correct. The parameter being passed needs to be the name of the property that changed, not some random text. Otherwise the system will never know where to look for the changed.
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com
Hi, Kindly suggest me how to use a DP as ConverterParameter in Xaml. Thnx, Ritesh