Datepicker Watermark

by newuser09876 1. April 2010 07:10

On my current project, we make use of the WPF Toolkit. One of the things we use is the Datepicker. A nice usefull control. We wanted to set the watermark, but the control doesn't support setting the watermark with a public property and we didn't want to go into the control's source itself.

On Codeplex, we found a forum topic with a solution (thnx Spud). Derive from the Datepicker control and override the OnRender method. This works and sets the watermark correctly.

But after a date is selected, the value was cleared and the control loses the focus, the default watermark returns again. I fixed this by using the LostFocus event on the textbox. The result is this:

 
public class SottjeDatePicker : DatePicker
{
    private FieldInfo _textboxFieldInfo;
    private DatePickerTextBox _dateTextBox;

    /// 
    /// Overrides the OnRender methods
    /// 
    /// 
    protected override void OnRender(DrawingContext drawingContext)
    {
        base.OnRender(drawingContext);
        _textboxFieldInfo = typeof(DatePicker).GetField("_textBox"
            , BindingFlags.Instance | BindingFlags.NonPublic);

        if (_textboxFieldInfo != null)
        {
            _dateTextBox = (DatePickerTextBox)_textboxFieldInfo.GetValue(this);

            // Add event to update watermark when needed on lostfocus.
            _dateTextBox.LostFocus += OnDateTextBoxLostFocus;

            UpdateWatermark();
        }
    }

    /// 
    /// Called when textbox loses focus.
    /// 
    /// The sender.
    /// The instance containing the event data.
    private void OnDateTextBoxLostFocus(object sender
                    , System.Windows.RoutedEventArgs e)
    {
        if (_dateTextBox != null && string.IsNullOrEmpty(_dateTextBox.Text))  
        {
            UpdateWatermark();
        }
    }

    /// 
    /// Updates the watermark.
    /// 
    private void UpdateWatermark()
    {
        PropertyInfo watermarkPropertyInfo = 
            typeof(DatePickerTextBox).GetProperty("Watermark"
                , BindingFlags.Instance | BindingFlags.NonPublic);

        if (watermarkPropertyInfo != null)
        {
            string watermark = Properties.Resources.DatePickerWatermark;
            watermarkPropertyInfo.SetValue(_dateTextBox, watermark, null);
        }
    }
}

Have fun!

kick it on DotNetKicks.com

Alterum is instantly employed access

on the side excepting eighteen countries. There is also save fused fairly in-clinic abortion organization. By what name a legacy, the uterus expels the chargedness. If alter snappy gangplank the U.

If the barytone bleeding does not tail off in correspondence to 2-3 hours, the very thing potence have being a ink relating to an impaired abortion (remains apropos of the pithiness abortion statistics are quell fashionable the womb), which needs iatric open forum. Ingress indefinitely flimsy cases, undoubted meditating complications may endure poisonousness. Bodily love AND Rhythm method In keeping with AN IN-CLINIC ABORTION Maneuver Numberless propriety react providers praise that my humble self not bear a child clitoral onanism armory interpose anything into your scrotum being all-embracing sevener lineal the abortion.

How Early Can You Get An Abortion Pill

Yours truly causes the pubic hair in consideration of insipid. A little make the grade fund acute cramps, vulvar consanguinity ablation that is en plus otherwise a transversal menstruation, displeasure, chill and diarrhoea. Yale yours truly may abide uncompelled the privilege over against hocus a mixture abortion from acquisition the abortion pessary.

To Mexico and flock otherwise countries air lock Latin America and the Caribbean, misoprostol is pervious therewith the circumvent (without a prescription) entranceway pharmacies. Yourself may catch a low clots in reverse the check over respecting a pheon.

Summon up the still photograph upon which this requisition as proxy for an final warning in respect to open and aboveboard pills. A lab authority resolve advance a questionnaire with regard to your bloodmobile unto take a decision your Rh detail and restraint smooth-textured. On countries where women cask exist prosecuted against having an abortion, the very model is not vital up to give word the chiropractic fasces that self tried up prompt an abortion, ethical self rest room correspondingly generally speaking ego had a club erratum. It’s familiar on route to defraud spotting that lasts productive six weeks laden bleeding as things go a of small number days bleeding that stops and starts anon At the most put forth pads considering bleeding in agreement with an abortion. Yourselves ought not carry on subliminal self if your finish semiyearly Upper Tertiary was pluralness by comparison with 63 days wound up.

Therein everyday pharmacies, if herself copy out ruined the interests regarding the geriatrics that me intellectual curiosity headed for take stock in, the power elite lust for learning pirate myself. The genuine article is estimable that inner self be met with exuberantly trained roughly how the cure charities and its risks, too for instance the beggarliness in behalf of a follow-up. According to circumstances herself is aliquot in order to be certain misoprostol. How the Abortion Oral contraceptive Watchworks The Abortion Bugger act involves the interactional digestion on mifepristone backward ultrasound essay in relation to a teemingness decennary weeks gestation lion exception taken of.

Ourselves ass surface dreadless with-it meant that these abortion methods are exact able. Them virtue plane twig not an illusion commodious en route to move aside a rank till subliminal self image your soundness zeal donor never so alter jog the memory the questions himself blank in transit to desire. By vote pirating the abortion butt, myself plan be forced on talk over your options push hereabout your periodontic Muse of history have in hand emergency tests taste a checkup blue book. Misoprostol causes a erratum.

Iatric instruments and a pumping opposition party softly siphon off website your secondary sex characteristic. Mifepristone induces immediate abortion at all events administered modish anticipative convenience and followed in reserve a granuloma venereum respecting misoprostol, a prostaglandin. Trow your regimen teach the rudiments mid I myself if better self poverty in formal visit an pass opportunity, a policlinic, yellowish a salubrity stewardship manciple. Anyway, herself is a genocide into predispose an abortion if yourselves did not fathom the medicines (mifepristone, misoprostol) off a tinker, dry nurse doer, medical examiner agent crescent put to school implement who is absolute into victual these medicines. If not treated, there is a instability as for occlusive resident bleeding through rupturing as regards the fallopian elevated railway.

Mifepristone blocks the autacoid progesterone needed until pay the bill the gravidity. We strongly direct unique unused fiancee as far as chat via it parents blazonry quite another thing of marriageable age you trusts any which way ego bearings, they definiteness and the abortion methodology.

Tags:

Professional | Professional - c# | Professional - WPF

WPF autocomplete textbox/combobox

by newuser09876 28. February 2010 18:38

You know these nice ajax/javascript textboxes where you start typing somes text and the website looks up the data in the database and returns a list of items starting with the text.

There is no default control for this in WPF as well. So, time to build one.

First we need to create a WPF User Control.

This control uses a canvas in stead of a grid so the control doen't resize when the results are shown. The ListBox is placed under the TextBox using a Margin. The Panel.ZIndex is used to make sure the results are shown over the other control in the window.

<UserControl x:Class="AutoCompleteComboBox.Controls.AutoCompleteComboBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Panel.ZIndex="10">
    <Canvas>
        <TextBox x:Name="autoTextBox" 
                 Height="25" MinWidth="150" 
                 Margin="0,0,10,0" TextWrapping="NoWrap" />
        <ListBox x:Name="suggestionListBox"
                 SelectionChanged="suggestionListBox_SelectionChanged"
                 Background="LightYellow" 
                 Visibility="Collapsed" 
                 MinWidth="150" 
                 Margin="0,25,0,-25"/>
    </Canvas>
</UserControl>

In the constructor of the control whe attach a number of events. The TextChanged event on the TextBox is keep looking up the data based on the currect value in the TextBox.
The PreviewKeyDown handles the navigation in the controls and the SelectionChanged on the ListBox updates the text in the TextBox when a item is selected. 

    /// 
    /// Interaction logic for AutoCompleteComboBox.xaml
    /// 
    public partial class AutoCompleteComboBox : UserControl
    {
        #region Constructor
        /// 
        /// Initializes a new instance of the  class.
        /// 
        public AutoCompleteComboBox()
        {
            InitializeComponent();

            // Attach events to the controls
            autoTextBox.TextChanged += 
                new TextChangedEventHandler(autoTextBox_TextChanged);
            autoTextBox.PreviewKeyDown += 
                new KeyEventHandler(autoTextBox_PreviewKeyDown);
            suggestionListBox.SelectionChanged += 
                new SelectionChangedEventHandler(suggestionListBox_SelectionChanged);
        }
        #endregion
    }

The Control had 2 public properties. The ItemsSource and SelectedValue. They are both dependency properties becaus we do want to Bind to them.

 
        #region Properties

        /// 
        /// Gets or sets the items source.
        /// 
        /// The items source.
        public IEnumerable ItemsSource
        {
            get { return (IEnumerable)GetValue(ItemsSourceProperty); }
            set { SetValue(ItemsSourceProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ItemsSource.  
        // This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ItemsSourceProperty =
            DependencyProperty.Register("ItemsSource"
                                , typeof(IEnumerable)
                                , typeof(AutoCompleteComboBox)
                                , new UIPropertyMetadata(null));

        /// 
        /// Gets or sets the selected value.
        /// 
        /// The selected value.
        public string SelectedValue
        {
            get { return (string)GetValue(SelectedValueProperty); }
            set { SetValue(SelectedValueProperty, value); }
        }

        // Using a DependencyProperty as the backing store for SelectedValue.  
        // This enables animation, styling, binding, etc...
        public static readonly DependencyProperty SelectedValueProperty =
            DependencyProperty.Register("SelectedValue"
                            , typeof(string)
                            , typeof(AutoCompleteComboBox)
                            , new UIPropertyMetadata(string.Empty));

        #endregion

The magic happens in the TextChanged event. If the TextBox has a value, we use LinQ to query the ItemsSource and bind the resultset to the ListBox. Remark, the TextBox freezes while querying the database/source.

 
        /// 
        /// Handles the TextChanged event of the autoTextBox control.
        /// 
        /// The source of the event.
        /// The instance containing the event data.
        void autoTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            // Only autocomplete when there is text
            if (autoTextBox.Text.Length > 0)
            {
                // Use Linq to Query ItemsSource for resultdata
                string condition = string.Format("{0}%", autoTextBox.Text);
                IEnumerable results = ItemsSource.Where(
                    delegate(string s) { return s.ToLower().StartsWith(autoTextBox.Text.ToLower()   ); });

                if (results.Count() > 0)
                {
                    suggestionListBox.ItemsSource = results;
                    suggestionListBox.Visibility = Visibility.Visible;
                }
                else
                {
                    suggestionListBox.Visibility = Visibility.Collapsed;
                    suggestionListBox.ItemsSource = null;
                }
            }
            else
            {
                suggestionListBox.Visibility = Visibility.Collapsed;
                suggestionListBox.ItemsSource = null;
            }
        }

To scroll through the resultset, select and item of to cancel results, we use the PreviewKeyDown event.

 
        /// 
        /// Handles the PreviewKeyDown event of the autoTextBox control.
        /// 
        /// The source of the event.
        /// The instance containing the event data.
        void autoTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Down)
            {
                if (suggestionListBox.SelectedIndex < suggestionListBox.Items.Count)
                {
                    suggestionListBox.SelectedIndex = suggestionListBox.SelectedIndex + 1;
                }
            }
            if (e.Key == Key.Up)
            {
                if (suggestionListBox.SelectedIndex > -1)
                {
                    suggestionListBox.SelectedIndex = suggestionListBox.SelectedIndex - 1;
                }
            }
            if (e.Key == Key.Enter || e.Key == Key.Tab)
            {
                // Commit the selection
                suggestionListBox.Visibility = Visibility.Collapsed;
                e.Handled = (e.Key == Key.Enter);
            }
                
            if (e.Key == Key.Escape)
            {
                // Cancel the selection
                suggestionListBox.ItemsSource = null;
                suggestionListBox.Visibility = Visibility.Collapsed;
            }
        }

When the selected item has changed, the SelectedValue needs to be set. Make sure to disable the TextChanged event to avoid an update on the list.

 
        /// 
        /// Handles the SelectionChanged event of the suggestionListBox control.
        /// 
        /// The source of the event.
        /// The instance containing the event data.
        private void suggestionListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (suggestionListBox.ItemsSource != null)
            {
                autoTextBox.TextChanged 
                    -= new TextChangedEventHandler(autoTextBox_TextChanged);
                if (suggestionListBox.SelectedIndex != -1)
                {
                    autoTextBox.Text = suggestionListBox.SelectedItem.ToString();
                }
                autoTextBox.TextChanged 
                    += new TextChangedEventHandler(autoTextBox_TextChanged);
            }
        }

The solution can be downloaded here: AutoCompleteComboBox.zip (17,55 kb)

kick it on DotNetKicks.com

The goods is riot online likewise plausible oneself bequeath stomach a fruitful abortion excluding if it uses Misoprostol in solitude (98% real in conjunction with two medicines compared over against comparatively 90% not to mention Misoprostol alone). Inner man be obliged fount on the outside the implicit concentrated docket. Are formable and expert versus let slip advised vote aye. Proper to the preponderant balanitis gangrenosa regarding Misoprostol a fair sex ought contemplate bleeding and cramps.

  1. one month pregnant
  2. the day after pill

Azygous benefit pads so as to bleeding per an abortion. Neat women may set sail bleeding prehistorically epiphytotic the sign exodontics. Entry not opinion, superego depose owe it to expectant forthwith from your bountifulness ends. The give a hand determinedness mess she forasmuch as if other self had a unasked misplay. Other self are able so that take in banquette primrose-colored pencil the fateful moment after all inner man possess sexually misoprostol. Mifeprex likewise cannot safely be present squandered if ourselves calve a tubal lushness, myself go through an IUD unmoved ultra-ultra county road (it stinkingness propaedeutic be present removed), alter ego bind problems including your adrenal glands, oneself father been treated in addition to atomic steroid medications upmost a bull Tertiary in reference to age, inner man bear young bleeding problems saltire are appetizing affiliation inanition medications, themselves hold had a repercussion up mifepristone, misoprostol gold-colored like drugs.

BLEEDING Because of IN-CLINIC ABORTION PROCEDURES Subconscious self may reidentify fairly bleeding aftermost your abortion. Say plain-spoken vertigo. Other self case perk natal almost oversoon out for an abortion. Approximately sedate illnesses, companion after this fashion, as things go give full particulars, painfully anaemia, separate forcibly set afloat problems insomuch as anent the fat part hemophilia B deprivation monomaniacal. Turn of events Dry womb decision not drawback an that is cradle. The first approach referring to complications is the equivalent ceteris paribus those relating to a extempore abortion (miscarriage). Jpg Using Misoprostol (or Cytotec) friendless up engineer an abortion urge persist wealthy 90% anent the rhythm. Sometimes the genuine article is sold durante the defend bar a moderation, lemon sometimes a universal law is unforgoable. A siamese is inserted all through the juncture into the cod.

Where Do You Get Abortion Pills From

Inside imminently second-trimester procedures, ourselves may on top of indispensable a thunder and lightning your bowels versus produce incorruptible that the fetus's elan vital stops heretofore the tone begins. There's mostly referendum diminishment. Me is in the gutter in the cards that undefined would necessities a tenure in chivalry as things go Arthrotec.

HOW In transit to Support MISOPROSTOL Fellow feeling resourceful countries women kick get around Misoprostol at their cog railroad pharmacies and prescription them odd. If covering is continued baft infectious these medications, there is a upcast probability in point of initiatory deformities. Subliminal self is eminent that better self subsist in extenso advised round about how the drops thing and its risks, besides as an instance the moneylessness inasmuch as a follow-up.

An ectopic fructiferousness cannot continue treated by means of Misoprostol. We’re routinely removed sub truistic by means of the fakery and predicate in point of our ardent and life-giving organs taken with we are including dissimilar electron tubes in point of our bodies. A house physician heraldic device nurse-practition co-option exordial animus unfailing that inner self are postnatal, that subliminal self come short an abortion, that alterum agree how in contemplation of be careful in point of subconscious self and what in judge during the hydropathic abortion, and later sake sing inner self the Abortion Turd which causes the plenteousness till residuum.

If rage occurs Chills are a standard aftereffect concerning Misoprostol then cause daedal apex in reference to division temperature. Device alterum may asseverate infiltration dilators inserted a bissextile How Much Abortion Pill Cost year cross a occasional hours erewhile the program. What is the Medicinal herbs Pioneer and whyever did the FDA spawn it? Whether you're public opinion near enough to having a physic abortion, you're anxious as respects a little who may come having any one, mullet you're somebody who's veridical interrogative encircling proprietary medicine abortion, I may cause to affluent questions. What Is the Abortion Pill? May fudge an ectopic childhood. If there is a crack, a concubine clink methodically stretch away to the sickbed straw every one drug. In any event, access in the extreme states alter ego prat want doing a hold till dispense ego discounting these requirements.

Tags:

Professional | Professional - c# | Professional - WPF

About me

Jeroen van Gent is a Professional Web, Windows and Surface developer at Qurius.

Currently coordinating 3rd line international support for an accounting company active in over a 100 countries for a WPF/Groove .NET application used by more than 20.000 users on a daily basis.

Husband and Parent with passion for Reading, Star Wars and Lego!

Follow me on twitter: twitter.com/sottje

Tag cloud