屋檐不懂雨 2019-11-29 13:58 采纳率: 0%
浏览 253

wpf button设置Focusable="False"后无法双向绑定无法获取到txtbox输入的值

wpf button设置Focusable="False"后,双向绑定txtbox的text,但是发现程序中通过model无法获取到txtbox的值了

  • 写回答

2条回答

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-10-27 15:56
    关注
    不知道你这个问题是否已经解决, 如果还没有解决的话:
    • 请看👉 :WPF开发(一)Button 自定义样式、字体大小及界面全屏显示
    • 除此之外, 这篇博客: WPF开发(一)Button 自定义样式、字体大小及界面全屏显示中的 二、ButtonEx.cs代码 部分也许能够解决你的问题, 你可以仔细阅读以下内容或者直接跳转源博客中阅读:
       public class ButtonEx : Button
          {
              static ButtonEx()
              {
                  DefaultStyleKeyProperty.OverrideMetadata(typeof(ButtonEx), new FrameworkPropertyMetadata(typeof(ButtonEx)));
              }
      
      
              public ButtonType ButtonType
              {
                  get { return (ButtonType)GetValue(ButtonTypeProperty); }
                  set { SetValue(ButtonTypeProperty, value); }
              }
      
              public static readonly DependencyProperty ButtonTypeProperty =
                  DependencyProperty.Register("ButtonType", typeof(ButtonType), typeof(ButtonEx), new PropertyMetadata(ButtonType.Normal));
      
      
              public ImageSource Icon
              {
                  get { return (ImageSource)GetValue(IconProperty); }
                  set { SetValue(IconProperty, value); }
              }
      
              public static readonly DependencyProperty IconProperty =
                  DependencyProperty.Register("Icon", typeof(ImageSource), typeof(ButtonEx), new PropertyMetadata(null));
      
      
              //ico改变
              public ImageSource ChangeIcon
              {
                  get { return (ImageSource)GetValue(ChangeIconProperty); }
                  set { SetValue(ChangeIconProperty, value); }
              }
              public static readonly DependencyProperty ChangeIconProperty =
                  DependencyProperty.Register("ChangeIcon", typeof(ImageSource), typeof(ButtonEx), new PropertyMetadata(null));
      
      
              public CornerRadius CornerRadius
              {
                  get { return (CornerRadius)GetValue(CornerRadiusProperty); }
                  set { SetValue(CornerRadiusProperty, value); }
              }
      
              public static readonly DependencyProperty CornerRadiusProperty =
                  DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ButtonEx), new PropertyMetadata(new CornerRadius(0)));
      
      
              public Brush MouseOverForeground
              {
                  get { return (Brush)GetValue(MouseOverForegroundProperty); }
                  set { SetValue(MouseOverForegroundProperty, value); }
              }
      
              public static readonly DependencyProperty MouseOverForegroundProperty =
                  DependencyProperty.Register("MouseOverForeground", typeof(Brush), typeof(ButtonEx), new PropertyMetadata());
      
      
              public Brush MousePressedForeground
              {
                  get { return (Brush)GetValue(MousePressedForegroundProperty); }
                  set { SetValue(MousePressedForegroundProperty, value); }
              }
      
              public static readonly DependencyProperty MousePressedForegroundProperty =
                  DependencyProperty.Register("MousePressedForeground", typeof(Brush), typeof(ButtonEx), new PropertyMetadata());
      
      
              public Brush MouseOverBorderbrush
              {
                  get { return (Brush)GetValue(MouseOverBorderbrushProperty); }
                  set { SetValue(MouseOverBorderbrushProperty, value); }
              }
      
              public static readonly DependencyProperty MouseOverBorderbrushProperty =
                  DependencyProperty.Register("MouseOverBorderbrush", typeof(Brush), typeof(ButtonEx), new PropertyMetadata());
      
      
              public Brush MouseOverBackground
              {
                  get { return (Brush)GetValue(MouseOverBackgroundProperty); }
                  set { SetValue(MouseOverBackgroundProperty, value); }
              }
      
              public static readonly DependencyProperty MouseOverBackgroundProperty =
                  DependencyProperty.Register("MouseOverBackground", typeof(Brush), typeof(ButtonEx), new PropertyMetadata());
      
      
              public Brush MousePressedBackground
              {
                  get { return (Brush)GetValue(MousePressedBackgroundProperty); }
                  set { SetValue(MousePressedBackgroundProperty, value); }
              }
      
              public static readonly DependencyProperty MousePressedBackgroundProperty =
                  DependencyProperty.Register("MousePressedBackground", typeof(Brush), typeof(ButtonEx), new PropertyMetadata());
          }
      
          public enum ButtonType
          {
              Normal,
              Icon,
              ChangeIcon,
              Text,
              IconText,
              ChangeIconText
          }
      

    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

悬赏问题

  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥60 SOL语句中Where查询中的 from to 语句能不能从小到大换成从大到小(标签-SQL)
  • ¥15 画两个图 python或R
  • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
  • ¥15 八路抢答器设计出现故障
  • ¥15 请教一下c语言的代码里有一个地方不懂
  • ¥15 opencv 无法读取视频
  • ¥15 用matlab 实现通信仿真
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))