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

  • SEARCH
  • Home
  • 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 8044467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:14:21+00:00 2026-06-05T05:14:21+00:00

I have a textblock that is binding to a double property called AdminTime in

  • 0

I have a textblock that is binding to a double property called “AdminTime” in my JobItem class. AdminTime calculates the total admin hours that are in an observablecollection called TimeLog. I use a textbox to add these admin hours into the JobItem class. Here is the scaled down code:

<TextBlock Style="{StaticResource TextBlockStyle}" Grid.Row="1" Grid.Column="1" Name="adminHrs" Text="{Binding Path=AdminTime, UpdateSourceTrigger=Explicit, Mode=OneWay, StringFormat={}{0:0.00}}" />
<TextBox Style="{StaticResource textBoundStyle}" Name="adminTimeTxtBox" Grid.Row="3" Grid.Column="1"  />
<Button Style="{StaticResource addTimeStyle}" Name="addAdBtn" Grid.Column="1" Grid.Row="3" Click="addAdBtn_Click" />
<Button Style="{StaticResource subTimeStyle}" Name="subAdBtn" Grid.Column="1" Grid.Row="3" Click="subAdBtn_Click" />

And for the code behind I have the addTime button click handler. Please note that I understand that my UpdateSourceTrigger is already on explicit and that I should not update my source, but I was just checking if it would help my problem:

public static readonly DependencyProperty AdminTimeProperty =
        DependencyProperty.Register("AdminTime", typeof(double),
        typeof(UpdateJobDialog));
private void addAdBtn_Click(object sender, RoutedEventArgs e)
    {
        AddHours();
    }

    private void AddHours()
    {
        item.AddTime(emp.UserType, emp.UserId, DateTime.Now, double.Parse(adminTimeTxtBox.Text));
        BindingExpression adHr = adminHrs.GetBindingExpression(TextBlock.TextProperty);
        adHr.UpdateSource();
    }

and in my JobItem Class, I have this code in place:

public double AdminTime
    {
        get
        {
            double newTime = 0.00;
            if (TimeLog != null)
            {
                foreach (HoursWorked hw in TimeLog)
                {
                    if (hw.EmployeeType == "Admin")
                        newTime += hw.Hours;
                }
            }
            adminTime = newTime;
            return adminTime;
        }

        set 
        {
            if (AdminTime != value)
            {
                adminTime = value;
                OnPropertyChanged("AdminTime");
            }
        }
    }

public void AddTime(string employeeType, string userId, DateTime datePosted, double hours)
    {
        HoursWorked newLog;
        newLog = new HoursWorked(employeeType, userId, datePosted, hours);
        TimeLog.Add(newLog);

    }

public ObservableCollection<HoursWorked> TimeLog
    {
        get { return timeLog; }
        set
        {
            if (!TimeLog.Equals(value))
            {
                timeLog = value;
                OnPropertyChanged("TimeLog");
            }
        }

    }

My textblock does bind when I exit the window and then reopen it, what I want is to have my textblock update once I click on the addAdBtn. I don’t want to have to open the dialog to be able to see my admin time textblock and button, add the time, close the dialog, and reopen again to see an updated textblock.

  • 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-06-05T05:14:24+00:00Added an answer on June 5, 2026 at 5:14 am

    I actually figured it out, I just needed to change my updatesourcetrigger to twoway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textblock within a GridView that is bound to a property that
I want to have a fixed-width TextBlock that has long, unbroken, horizontal text, and
I have a WPF view that displays a Shipment entity. I have a textblock
I have WPF Span that is used as a source to a TextBlock. I
I have a Textblock which Text attribute is binding to a DateTime? type data,
I have a window in one assembly that has a TextBlock control that I
I have a data grid that looks like this <tk:DataGrid ItemsSource={Binding Parents} AutoGenerateColumns=False> <tk:DataGrid.Columns>
I have a TextBlock that's on top of a Button in a Grid .
I have a TextBlock that I want to display a user name, and email
I have a style for a textblock that is set inside my app.xaml this

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.