Skip to main content

Microsoft Silverlight

Unanswered Question Dependency properties.RSS Feed

(0)

vladc77
vladc77

Member

Member

1 points

27 Posts

Dependency properties.

Hello,

I am wondering if someone can share with the best technique on how to control the value change using the slider with dependency property in C#. I need to update the value change based on slider position. It is something new for me and I'd like to find out about the best way to approach this. Below is the XAML code of the slider I created. Thank you in advance.

 <Slider x:Name="MaxAccelerationSlider" Margin="0"
    Maximum="3" Minimum="1.5" Value="2"
    AutoToolTipPlacement="TopLeft"
    TickPlacement="None" AutoToolTipPrecision="2"
    IsSnapToTickEnabled="True"
    ValueChanged="OnMaxAccelerationChanged"
    IsMoveToPointEnabled="True"
    TabIndex="4" TickFrequency="0.05"
    
    />

 

Sergey.Lutay
Sergey.L...

Contributor

Contributor

7252 points

1,352 Posts

Re: Dependency properties.

Hi,

Look at Element To Element binding sample. Another one sample.

(If this has answered your question, please click on "mark as answer" on this post. Thank you!)

Blog

Twitter

Sincerely,
Sergey Lutay

vladc77
vladc77

Member

Member

1 points

27 Posts

Re: Re: Dependency properties.

Thank you for the reply, however, it is not what I am trying to solve.

I have a class "ScrollViewer" in which i control behavior of the scrolling. I want to be able to change the behavior by using the slider which is in a separate window. It is like a control box window. I created the partial class "Controls" where I define all controls in XAML. I need to pass the changed value from here to "MyScrollViewer" class.

In Controls.xaml.cs I am trying to use dependency property this way. It is just a concept:

public static readonly DependencyProperty MaxAccelerationProperty = DependencyProperty.Register("MaxAcceleration", typeof(double), typeof(MyScrollViewer), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsParentArrange));

//

private static void OnMaxAccelerationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

{

((
Globals.MaxAcceleration)d).OnMaxAccelerationChanged(e);

}

//
private void OnMaxAccelerationChanged(DependencyPropertyChangedEventArgs e){

}

//

public double MaxAcceleraton

{

get { return (double)GetValue(MaxAccelerationProperty); }set { SetValue(MaxAccelerationProperty, value); }

}

I have problems to bind the value from the Slider and then to make it available for "ScrollViewer" class where "Globals.MaxAcceleration" should be the new set Value. I hope it make sence. It just new area form me which I am trying to learn how to manage it. Please let me know if you have any ideas on it. Thanks.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities