コード例 #1
0
        /// <summary>
        /// Show the watermark on the specified control
        /// </summary>
        /// <param name="control">Control to show the watermark on</param>
        private static void ShowWatermark(Control control)
        {
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(control);

            // layer could be null if control is no longer in the visual tree
            if (layer != null)
            {
                var wm = new WatermarkAdorner(control, GetWatermark(control));
                // Comboboxes render slightly differently
                if (control is ComboBox)
                {
                    wm.Margin = new Thickness(0, -2, 0, 0);
                }
                layer.Add(wm);
            }
        }
コード例 #2
0
        /// <summary>
        /// Show the watermark on the specified control
        /// </summary>
        /// <param name="control">Control to show the watermark on</param>
        private static void ShowWatermark(Control control)
        {
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(control);

            // layer could be null if control is no longer in the visual tree
            if (layer != null)
            {
                var wm = new WatermarkAdorner(control, GetWatermark(control));
                // Comboboxes render slightly differently
                if (control is ComboBox)
                {
                    wm.Margin = new Thickness(0, -2, 0, 0);
                }
                layer.Add(wm);
            }
        }