Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Scaling woes

Scaling woes

Scheduled Pinned Locked Moved WPF
wpfcsharpcsswcfhelp
16 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Ray Hayes

    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

    T Offline
    T Offline
    TJoe
    wrote on last edited by
    #7

    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

    R 1 Reply Last reply
    0
    • T TJoe

      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

      R Offline
      R Offline
      Ray Hayes
      wrote on last edited by
      #8

      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

      T 1 Reply Last reply
      0
      • R Ray Hayes

        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

        T Offline
        T Offline
        TJoe
        wrote on last edited by
        #9

        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

        R 1 Reply Last reply
        0
        • T TJoe

          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

          R Offline
          R Offline
          Ray Hayes
          wrote on last edited by
          #10

          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

          T 1 Reply Last reply
          0
          • R Ray Hayes

            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

            T Offline
            T Offline
            TJoe
            wrote on last edited by
            #11

            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

            R 1 Reply Last reply
            0
            • T TJoe

              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

              R Offline
              R Offline
              Ray Hayes
              wrote on last edited by
              #12

              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

              T 2 Replies Last reply
              0
              • R Ray Hayes

                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

                T Offline
                T Offline
                TJoe
                wrote on last edited by
                #13

                You still get the same binding error with that change?

                Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com

                1 Reply Last reply
                0
                • R Ray Hayes

                  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

                  T Offline
                  T Offline
                  TJoe
                  wrote on last edited by
                  #14

                  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

                  R U 2 Replies Last reply
                  0
                  • T TJoe

                    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

                    R Offline
                    R Offline
                    Ray Hayes
                    wrote on last edited by
                    #15

                    PERFECT... that was it. Thanks a lot Tom, I felt I've learned a lot with your help! Thanks again!

                    Regards, Ray

                    1 Reply Last reply
                    0
                    • T TJoe

                      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

                      U Offline
                      U Offline
                      User 3671134
                      wrote on last edited by
                      #16

                      Hi, Kindly suggest me how to use a DP as ConverterParameter in Xaml. Thnx, Ritesh

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups