3 回答

TA貢獻1797條經驗 獲得超6個贊
metadata中跟一個靜態方法看我這個定義(在RichTextBlock家一個TextProperty,TextProperty類型是字符串): public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(RichTextBlock), new PropertyMetadata(OnBlockTextChanged)); public string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); SetLinkedText(value); } } static void OnBlockTextChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { if (obj != null && obj is RichTextBlock) { (obj as RichTextBlock).SetLinkedText((string)e.NewValue); } }

TA貢獻1831條經驗 獲得超4個贊
追問下 我想實現這個功能,所以才這樣定義!不然采用什么方法比較好呢?在一個頁面嵌套了一個用戶控件,通過用戶控件里面的事件來控制那個頁面里面的控件的隱藏,可是都沒效?可是如果我在這個頁面后臺單獨操作頁面的控件,就可以正常隱藏?例如有個A.xaml頁面,里面嵌套一個B.Xaml的用戶控件,現在在B.Xaml的后臺通過 A a=new A();a.hide();調用A頁面里面的函數,可是這個函數執行了,但是對應A頁面上的控件例如button沒有隱藏?
添加回答
舉報