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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:57:29+00:00 2026-05-12T21:57:29+00:00

I have created a XAML UserControl that is used to enter the current date

  • 0

I have created a XAML UserControl that is used to enter the current date using some up/down controls. The interesting parts of the UserControl are as follows:

<UserControl x:Class="MyApp.Controls.DateEntry"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:uControl="clr-namespace:MyApp.Controls"
xmlns:uConverters="clr-namespace:MyApp.Converters"
x:Name="dateEntry">

etc...
Here's where the numeric up/down controls are defined

<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
    <uControl:NumericEntry x:Name="monthEntry" Label="Month" Style="{StaticResource SmallNumericEntry}" Maximum="12" Number="{Binding Path=Month, ElementName=dateEntry, Mode=TwoWay}" Minimum="1"/>
    <uControl:NumericEntry x:Name="dayEntry" Label="Day" Style="{StaticResource SmallNumericEntry}" Margin="10,0,0,0" Maximum="31" Number="{Binding ElementName=dateEntry, Path=Day, Mode=TwoWay}" Minimum="1"/>
    <uControl:NumericEntry x:Name="yearEntry" Label="Year" Style="{StaticResource LargeNumericEntry}" Margin="10,0,0,0" Maximum="9999" Number="{Binding ElementName=dateEntry, Path=Year, Mode=TwoWay}" Minimum="1"/>
</StackPanel>

You can see how certain properties of the NumericEntries are defined (e.g. For yearEntry, Maximum=”9999″). Now what I want to do, is allow any anyone who uses this UserControl in their XAML code to be able to modify this property. Here’s some XAML (seperate file) that uses this UserControl:

<uControl:DateEntry
            x:Name="treatmentDate"
            Date="{Binding Source={StaticResource currentTreatment}, Path=Date, Mode=TwoWay}"
            Margin="10" />

I want to override the value of yearEntry.Maximum to be 2099. However, in the XAML file that uses the UserControl, it doesn’t have visibility to yearEntry. It is possible to modify this programatically in the .cs file, but this kind of definition surely belongs in the XAML file.

Thanks in advance for your responses!

  • 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-12T21:57:29+00:00Added an answer on May 12, 2026 at 9:57 pm

    if your dateEntry class had a dependency property for maximum year, you could bind to them from any control that uses them. then your code to set the year would look like this

    <uControl:NumericEntry 
      x:Name="yearEntry" 
      Label="Year" 
      Style="{StaticResource LargeNumericEntry}" 
      Margin="10,0,0,0" 
      Maximum="{Binding ElementName=dateEntry, Path=MaximumYear}" 
      Number="{Binding ElementName=dateEntry, Path=Year, Mode=TwoWay}" 
      Minimum="1"/>
    

    and in your code behind you could set the max to 9999 in the dependency props definition

      public int MaximumYear {
         get { return (int)GetValue(MaximumYearProperty); }
         set { SetValue(MaximumYearProperty, value); }
      }
    
      public static readonly DependencyProperty MaximumYearProperty =
          DependencyProperty.Register("MaximumYear", typeof(int), typeof(NumericEntry), new UIPropertyMetadata(9999));
    

    then use it like this

    <uControl:DateEntry
      x:Name="treatmentDate"
      Date="{Binding Source={StaticResource currentTreatment}, Path=Date, Mode=TwoWay}"
      MaximumYear="9999"
      Margin="10" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have authored some custom classes that I would like to create using XAML:
I have created a UserControl that has a ListView in it. The ListView is
I have created a custom panel (MyCustomControl) that can contain other controls and be
I have a control library that consists of only UserControl derived controls. I am
I am trying to set twoway binding on a UserControl that I have created.
I have created a trigger in the xaml and it works fine. However, when
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a PHP-script to update a web server that is live inside
I have created a C# class file by using a XSD-file as an input.
I have created a few small flash widgets that stream .mp3 audio from an

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.