Solved

WPF - External data binding to controls inside a UserControl

Posted on 2016-08-31
2
94 Views
Last Modified: 2016-09-01
In my project I am developing a UserControl that has a slider and some other controls inside it. I need to data bind to some of these controls, for example the Minimum, Maximum, and Value of the slider control. As an initial step I have created a Dependency Property on the UserControl for the "Value" property of the slider, it is called "Volume."

	Public Shared ReadOnly volumeProperty As DependencyProperty = DependencyProperty.Register("volume", GetType(Double), GetType(CA_Fader))

	Public Property volume As Double
		Get
			Return CDbl(GetValue(volumeProperty))
		End Get
		Set(value As Double)
			SetValue(volumeProperty, value)
		End Set
	End Property

Open in new window


The UserControl has this binding for the slider value property:

            <Slider x:Name="slider" Value="{Binding volume, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" Orientation="Vertical" Maximum="1" LargeChange="0.1" SmallChange="0.01" Width="30" Margin="11,4,0,3"/>

Open in new window


The user control is used on the main form of the application and I attempted to data bind the volume property like this:

                <local:CA_Fader x:Name="slider2" volume="{Binding CuePlayManager.TheMixer.MasterVolume}" Height="140" Width="74" Margin="0,2"/>

Open in new window


However, when I use the slider the "MasterVolume" property is not being updated.

Any input would be greatly appreciated,
Sid
0
Comment
Question by:Sid Price
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Accepted Solution

by:
Sid Price earned 0 total points
ID: 41780077
I have resolved this issue myself, it appears the default binding on my UserControl "volume" property was one-way. I changed the binding as shown below and it now works:

                <local:CA_Fader x:Name="slider2" volume="{Binding CuePlayManager.TheMixer.MasterVolume, Mode-TwoWay}" Height="140" Width="74" Margin="0,2"/>

Open in new window


Sid
0
 

Author Closing Comment

by:Sid Price
ID: 41780079
Resolved through own research and debugging
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question