Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6171743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:16:12+00:00 2026-05-23T23:16:12+00:00

I’ve got a dialog box that is opened by my main window. Among other

  • 0

I’ve got a dialog box that is opened by my main window. Among other things, it has a custom control I wrote that is supposed to control the volume of any MediaElement controls in the program.

The volume control contains 2 buttons and a ProgressBar. It has a Volume DependencyProperty. When you click on the volume up button, the value of the Volume property increases by 5%; similarly, clicking on the volume down button decreases the volume by 5%. This is reflected in the ProgressBar. I’m confident the ProgressBar is working, but I won’t rule out issues in there.

The dialog box has its own Volume DependencyProperty, as does the main window, for that matter. I tried to bind the Volume property of the Volume control in the Dialog to the dialog’s Volume property. I even added a text field to the dialog to tell me what the value of the Volume property is. I figured that I needed this to make sure the dialog’s volume was really changing. It doesn’t seem to be changing at all.

Here’s an excerpt of the xaml for the dialog box. It’s missing some things that aren’t related to this problem.

<Window x:Class="CarSystem.SettingsDialog" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:c="clr-namespace:CarSystem"
        xmlns:cs="clr-namespace:CarSystem.CustomControls;assembly=CustomControls" 
        Closed="SettingsDialog_Closed"
        Height="300" 
        ResizeMode="NoResize" 
        Title="Settings" 
        Width="550" 
        WindowStartupLocation="CenterOwner" 
        WindowStyle="None">

    <StackPanel>

        <StackPanel Grid.Column="2" Orientation="Horizontal">
            <TextBlock FontSize="20" 
                       FontWeight="Bold" 
                       Foreground="White" 
                       Margin="10" 
                       Text="Volume: " 
                       VerticalAlignment="Center" />
            <TextBlock FontSize="20" 
                       FontWeight="Bold" 
                       Foreground="White" 
                       Margin="10" 
                       Text="{Binding Mode=OneWay, Path=Volume, RelativeSource={RelativeSource AncestorType={x:Type c:SettingsDialog}}}" 
                       VerticalAlignment="Center" />
        </StackPanel>

        <StackPanel>

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <cs:VolumeControl Grid.Row="0" 
                              Height="60" 
                                  HorizontalAlignment="Left" 
                                  Margin="20,0,0,0" 
                                  Volume="{Binding Mode=OneWay, Path=Volume, RelativeSource={RelativeSource AncestorType={x:Type c:SettingsDialog}}}" 
                                  Width="325" />

                <Button Background="#FF3C4B66" 
                        Click="CloseButton_Click" 
                        Content="Close" 
                        FontSize="20" 
                        FontWeight="Bold" 
                        Foreground="White" 
                        Grid.Row="1" 
                        Height="50"
                        HorizontalAlignment="Right" 
                        Margin="0,5,20,5" 
                        Width="125" />
                </Grid>
            </StackPanel>
        </Border>

    </StackPanel>

</Window>

Here’s the code-behind for the Volume control:

public partial class VolumeControl : Control {

    public static readonly DependencyProperty VolumeProperty = 
        DependencyProperty.Register( "Volume", typeof( double ), typeof( VolumeControl ), new FrameworkPropertyMetadata( 0.50 ) );

    public double Volume {
        get { return (double) GetValue( VolumeProperty ); }
        set { SetValue( VolumeProperty, value ); }
    }

    public VolumeControl() {
        Loaded += WasLoaded;
    }

    static VolumeControl() {
        DefaultStyleKeyProperty.OverrideMetadata( typeof( VolumeControl ), new FrameworkPropertyMetadata( typeof( VolumeControl ) ) );
    }

    private void VolumeDown_Click( object sender, RoutedEventArgs e ) {
        Volume = Math.Max( 0, Volume - 0.05 );
    }

    private void VolumeUp_Click( object sender, RoutedEventArgs e ) {
        Volume = Math.Min( 1.0, Volume + 0.05 );
    }

    private void WasLoaded( object sender, EventArgs e ) {
        RepeatButton VolumeUpButton = (RepeatButton) Template.FindName( "PART_VolumeUp", this );
        if ( VolumeUpButton != null ) {
            VolumeUpButton.Click += VolumeUp_Click;
        }

        RepeatButton VolumeDnButton = (RepeatButton) Template.FindName( "PART_VolumeDown", this );
        if ( VolumeDnButton != null ) {
            VolumeDnButton.Click += VolumeDown_Click;
        }
    }
}

As I said, the Output window doesn’t display any error messages, which is what WPF does when binding fail. Yet the value displayed by TextBlock that’s bound to the dialog’s Volume property doesn’t change. Is the problem in the TextBlock binding, the Volume control’s binding, or in the VolumeControl itself?

Tony

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:16:14+00:00Added an answer on May 23, 2026 at 11:16 pm

    It appears that you have two Volume properties in play here. The first is on VolumeControl, which you show the code for. The other is on SettingsDialog, which you only show the XAML for.

    Your TextBlock and VolumeControl are both bound to the Volume on your SettingsDialog, but it doesn’t look like anything would update that property. You probably meant to use TwoWay binding on VolumeControl, like so:

    <cs:VolumeControl ...
        Volume="{Binding Mode=TwoWay, Path=Volume, RelativeSource={RelativeSource AncestorType={x:Type c:SettingsDialog}}}" ... />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
i got an object with contents of html markup in it, for example: string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.