/// <summary> /// MaxLinesプロパティが変更された際の処理 /// </summary> private static void OnSetMaxLinesCallback(DependencyObject target, DependencyPropertyChangedEventArgs e) { var textblock = target as TextBlock; if (textblock == null) { return; } if (textblock.TextWrapping == TextWrapping.NoWrap) { // 改行設定 textblock.TextWrapping = TextWrapping.Wrap; } if (textblock.TextTrimming == TextTrimming.None) { // 省略文字設定 textblock.TextTrimming = TextTrimming.CharacterEllipsis; } BehaviorUtil.SetEventHandler(textblock, (block) => block.TargetUpdated += TextBlock_TargetUpdated, (block) => block.TargetUpdated -= TextBlock_TargetUpdated ); BehaviorUtil.Loaded(textblock, TextBlock_Loaded); }
private static void OnSetIsEnabledCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e) { if (!WpfUtil.IsDesignMode()) { // Window読込時イベント BehaviorUtil.Loaded(sender as Window, Window_Loaded); } }
/// <summary> /// Valueプロパティが変更された際の処理 /// </summary> /// <param name="target">対象</param> /// <param name="e">イベント情報</param> private static void OnSetFormatCallback(DependencyObject target, DependencyPropertyChangedEventArgs e) { var textbox = target as TextBox; var value = WpfUtil.GetIsNotNull(GetValue(textbox), textbox.Text, "0"); BehaviorUtil.Loaded(textbox, (sender, tmp) => SetText(textbox, double.Parse(value)) ); }
/// <summary> /// コマンドプロパティが変更された際の処理 /// </summary> /// <param name="target">対象</param> /// <param name="e">イベント情報</param> private static void OnSetCommandCallback(DependencyObject target, DependencyPropertyChangedEventArgs e) { var obj = target as DependencyObject; if (obj != null) { BehaviorUtil.Loaded(target as FrameworkElement, UserControl_Loaded); } }
/// <summary> /// IsEnabledプロパティが変更された際の処理 /// </summary> /// <param name="target">対象</param> /// <param name="e">イベント情報</param> private static void OnSetIsEnableCallback(DependencyObject target, DependencyPropertyChangedEventArgs e) { var label = target as Label; BehaviorUtil.SetEventHandler(label, (fe) => fe.SizeChanged += Label_SizeChanged, (fe) => fe.SizeChanged -= Label_SizeChanged ); BehaviorUtil.Loaded(label, Label_Loaded); }
private static void OnSetIsEnabledCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var element = sender as ListView; // 基本的にListView.SizeChangedイベントで列幅を変更する。 BehaviorUtil.SetEventHandler(element, fe => fe.SizeChanged += ListView_SizeChanged, fe => fe.SizeChanged -= ListView_SizeChanged ); // 初期表示時にSizeChangedイベントが発生しなかったのでコントロール読込後に1回だけ手動で実行する。 BehaviorUtil.Loaded(element, (listview, tmp) => ListView_SizeChanged(listview, null) ); }
/// <summary> /// Valueプロパティが変更された際の処理 /// </summary> /// <param name="target">対象</param> /// <param name="e">イベント情報</param> private static void OnSetValueCallback(DependencyObject target, DependencyPropertyChangedEventArgs e) { var textbox = target as TextBox; BehaviorUtil.SetEventHandler(textbox, (fe) => fe.GotFocus += TextBox_GotFocus, (fe) => fe.GotFocus -= TextBox_GotFocus ); BehaviorUtil.SetEventHandler(textbox, (fe) => fe.LostFocus += TextBox_LostFocus, (fe) => fe.LostFocus -= TextBox_LostFocus ); BehaviorUtil.Loaded(textbox, (sender, tmp) => SetText(textbox, (double)e.NewValue) ); }
/// <summary> /// ヘッダプロパティが変更された際の処理 /// </summary> /// <param name="sender">対象</param> /// <param name="e">イベント情報</param> private static void OnHeaderCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var viewer = BehaviorUtil.GetScrollViewer(sender as FrameworkElement); BehaviorUtil.SetEventHandler(viewer, (sv) => sv.ScrollChanged += ScrollViewer_ScrollChanged, (sv) => sv.ScrollChanged -= ScrollViewer_ScrollChanged ); var target = e.NewValue as FrameworkElement; BehaviorUtil.SetEventHandler(target, (sv) => sv.PreviewMouseWheel += FrameworkElement_MouseWheel, (sv) => sv.PreviewMouseWheel -= FrameworkElement_MouseWheel ); BehaviorUtil.Loaded(viewer, ScrollViewer_Loaded); }
/// <summary> /// ToolTipプロパティが変更された際の処理 /// </summary> /// <param name="target">対象</param> /// <param name="e">イベント情報</param> private static void OnSetToolTipCallback(DependencyObject target, DependencyPropertyChangedEventArgs e) { var control = target as Control; BehaviorUtil.Loaded(control, Control_Loaded); }