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 7530865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:01:52+00:00 2026-05-30T05:01:52+00:00

I want a textbox which will always applied a Converter on the binding. this

  • 0

I want a textbox which will always applied a Converter on the binding. this way I don’t need to specified the converter, the style will already contains the converter to use.

This is what I already tried:

I have a ViewModel bound to view. I override the datacontext of a textbox within this view using a property of the view model. It allows me to use a generic style for my text box

I have the following Style:

<Style x:Key="DateTimeTextBox" TargetType="TextBox">
    <Setter Property="ToolTipService.ShowDuration" Value ="40000"/>
    <Setter Property="Text" Value ="{Binding Path=.,Converter={StaticResource myConverter},UpdateSourceTrigger=PropertyChanged}"/> 
    <Style.Triggers>
      <Trigger Property="Validation.HasError" Value="true">
        <Setter Property="ToolTip" Value="Unknown date format"/>
      </Trigger>
    </Style.Triggers>
</Style>

In the view I want to have the following text box bound on the porperty DateTimeValueToBind instead of the whole view model:

<TextBox Style="{StaticResource DateTimeTextBox}" DataContext="{Binding DateTimeValueToBind}"/>

The property DateTimeValueToBind is displayed properly in the textbox however it’s not bound anymore (when I modified it, the viewmodel property is not changed)

I tried to add the Mode=TwoWay in the binding options but It did not change anything.

Could explain why the DateTimeValueToBind property is not bound anymore in this context?

Thanks in advance

  • 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-30T05:01:53+00:00Added an answer on May 30, 2026 at 5:01 am

    Leave the DataContext, bind the Text to DateTimeValueToBind (move the binding from the DataContext to Text). You should never set such a binding in a style; if the path is . you cannot bind TwoWay. (And what did you save anyway? You even have more to write as "DataContext" is longer than "Text".)

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

Sidebar

Related Questions

i want to make a textbox in my wpf application which will accept only
I need some help. Don't know if this is possible. I want to have
I have an asp.net TextBox in which I want to check if the text
I want to add style in ASP.NET textbox control. I couldn't find textbox element
I want to create a program which calculates how long it will take to
I have a textbox.T he user will be entering entering a number in this
I am having a Password textbox which will have empty value. when the user
I have a HTML checkbox which will perform a simple validation on another textbox,
I am trying to create an autocomplete textbox using jquery which will be bound
In silverlight, I got a textbox which I want to be multiline and have

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.