silverlight - How to bind SelectionStart Property of Text Box? -
मैं इसे का उपयोग करता हूं:
& gt; टेक्स्ट बॉक्स एक्स: नाम = "टेस्ट" / & gt ; & Lt; टेक्स्टब्लॉक टेक्स्ट = "{बाध्य चयन चयन, एलिमेंटनाम = परीक्षण}" / & gt;
लेकिन यह हमेशा 0 दिखाता है। यह कैसे हो सकता है?
धन्यवाद।
मैं इस समस्या में पड़ गए (selectionstart और SelectionLength गुण निर्भरता नहीं कर रहे हैं) और bindable चयन आरंभ और अंत के साथ एक पाठ बॉक्स बनाने का फैसला किया:
सार्वजनिक वर्ग SelectionBindingTextBox: पाठ बॉक्स {public static केवल पढ़ने के लिए DependencyProperty BindableSelectionStartProperty = DependencyProperty.Register ( "BindableSelectionStart", typeof (पूर्णांक), typeof (SelectionBindingTextBox), नई PropertyMetadata (OnBindableSelectionStartChanged)); सार्वजनिक स्थैतिक केवल पढ़ने के लिए DependencyProperty BindableSelectionLengthProperty = DependencyProperty.Register ( "BindableSelectionLength", typeof (पूर्णांक), typeof (SelectionBindingTextBox), नई PropertyMetadata (OnBindableSelectionLengthChanged)); निजी bool परिवर्तन FROMUI; सार्वजनिक चयन-बाइंडिंग टेक्स्टबॉक्स (): बेस () {this.SelectionChanged + = this.OnSelectionChanged; } सार्वजनिक इंट BindableSelectionStart {get {return (int) this.GetValue (BindableSelectionStartProperty); } सेट {this.SetValue (BindableSelectionStartProperty, मान); }} सार्वजनिक int BindableSelectionLength {get {return (int) this.GetValue (BindableSelectionLengthProperty); } सेट {this.SetValue (BindableSelectionLengthProperty, मान); }} निजी स्थिर शून्य OnBindableSelectionStartChanged (DependencyObject dependencyObject, आर्ग DependencyPropertyChangedEventArgs) {var पाठ बॉक्स = SelectionBindingTextBox रूप dependencyObject; अगर (! TextBox.changeFromUI) {int newValue = (int) args.NewValue; Textbox.selectionStart = newValue; } अन्य {textBox.changeFromUI = false; }} निजी स्थिर शून्य OnBindableSelectionLengthChanged (DependencyObject dependencyObject, आर्ग DependencyPropertyChangedEventArgs) {var पाठ बॉक्स = SelectionBindingTextBox रूप dependencyObject; अगर (! TextBox.changeFromUI) {int newValue = (int) args.NewValue; पाठ बॉक्स। चयनलाल = नयाव्यू; } अन्य {textBox.changeFromUI = false; }} निजी शून्य OnSelectionChanged (वस्तु प्रेषक, RoutedEventArgs ई) {if (this.BindableSelectionStart = this.SelectionStart!) {This.changeFromUI = true This.BindableSelectionStart = this.SelectionStart; } अगर (यह.बिन्डेबलसैक्शनलथेंबली! = यह। सेलेक्शन लैंग) {this.changeFromUI = true; यह.बिन्डाएबलसेलेक्शन = लम्बाई। }}}
Comments
Post a Comment