سلام
چطور میتونم موقع تایپ در تکس باکس یک Pop UP باز بشه و نوشته را در خاصیت Change تکس باکس نشون بده.
(برای نوشتن مقادیر عددی که بصورت کاما یا سه رقم سه رقم جدا کنه و pop up بشه نشون دارد)
تشکر
اصلا منظورتون رو متوجه نشدم
3 رقم جدا کردن و popup ربطشون با هم رو بیشتر توضیح دهید
میخوام وقتی کاربر درون تکس باکس نوشته ای را تایپ میکنه بصورت پاپ آپ این مقدار نمایش داده بشه.
(حالا این مقدار عددی است و میخوام بصورت سه رقم سه رقم از هم جدا بشن)
این کد زمانی که که تکس باکس فوکوس دریافت کند صفحه کلید نمایش می یابد با تغییر آن می توانید متن در حال تایپ را به هر شکلی نمایش دهید. public class CustomTextBox : TextBox { Style style() { Style style = new Style(typeof(Button)); style.Setters.Add(new Setter() { Property = Control.BackgroundProperty, Value = null }); style.Triggers.Add(new Trigger() { Property = Control.IsMouseOverProperty, Value = true, Setters = { new Setter() {Property = BackgroundProperty,Value = null}, new Setter() {Property = BorderBrushProperty,Value = Brushes.DarkGray}, } }); return style; } private readonly Popup _popup; public PlacementMode PlacementMode { get; set; } public CustomTextBox() { PlacementMode = PlacementMode.Bottom; //TODO: Repair This WrapPanel uniformGrid = new WrapPanel(); for (int i = 9; i >= 0; i--) { Button btn = new Button() { Content = i, Width = 60, Height = 30,BorderThickness = new Thickness(1),FontWeight = FontWeights.Normal}; btn.Style = style(); btn.Click += Btn_Click; uniformGrid.Children.Add(btn); } Button btnBackSpace = new Button() {Style = null,Content = "BackSpace", Width = 120, Height = 30,HorizontalAlignment = HorizontalAlignment.Center}; btnBackSpace.Click += Btn_Click; btnBackSpace.Style = style(); uniformGrid.Children.Add(btnBackSpace); uniformGrid.Background = Brushes.White; StackPanel stackPanel = new StackPanel(); stackPanel.Children.Add(uniformGrid); _popup = new Popup { Child = stackPanel, PlacementTarget = this, StaysOpen = true, Width = 180, }; _popup.Margin = new Thickness { Left = -5 }; _popup.GotFocus += _popup_GotFocus; _popup.GotTouchCapture += _popup_GotFocus; } private void _popup_GotFocus(object sender, RoutedEventArgs e) { Show(); } private void Btn_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if (button != null) { if (button.Content.Equals("BackSpace")) { if (Text.Length - 1 > 0) Text = Text.Remove(Text.Length - 1, 1); else if (Text.Length - 1 == 0) Text = "0"; } else { Text += button.Content; } } //Show(); } protected override void OnMouseDown(MouseButtonEventArgs e) { Show(); base.OnMouseDown(e); } protected override void OnGotTouchCapture(TouchEventArgs e) { Show(); base.OnGotTouchCapture(e); } private void Show() { if (_popup != null) { _popup.Placement = PlacementMode; _popup.IsOpen = true; } } private void Hide() { if (_popup != null) _popup.IsOpen = false; } protected override void OnGotFocus(RoutedEventArgs e) { Show(); base.OnGotFocus(e); } protected override void OnLostFocus(RoutedEventArgs e) { Hide(); base.OnLostFocus(e); } protected override void OnLostTouchCapture(TouchEventArgs e) { Hide(); base.OnLostTouchCapture(e); } }
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)