Where is the WPF Numeric UpDown control?

后端 未结 13 1856
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 00:02

Getting into the first serious WPF project. It seems like there are a lot of basic controls flat out missing. Specifically, I am looking for the Numeric UpDown control. W

13条回答
  •  伪装坚强ぢ
    2020-11-30 00:36

    Use VerticalScrollBar with the TextBlock control in WPF. In your code behind, add the following code:

    In the constructor, define an event handler for the scrollbar:

    scrollBar1.ValueChanged += new RoutedPropertyChangedEventHandler(scrollBar1_ValueChanged);
    scrollBar1.Minimum = 0;
    scrollBar1.Maximum = 1;
    scrollBar1.SmallChange = 0.1;
    

    Then in the event handler, add:

    void scrollBar1_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
    {
        FteHolderText.Text = scrollBar1.Value.ToString();
    }
    

    Here is the original snippet from my code... make necessary changes.. :)

    public NewProjectPlan()
    {
        InitializeComponent();
    
        this.Loaded += new RoutedEventHandler(NewProjectPlan_Loaded);
    
        scrollBar1.ValueChanged += new RoutedPropertyChangedEventHandler(scrollBar1_ValueChanged);
        scrollBar1.Minimum = 0;
        scrollBar1.Maximum = 1;
        scrollBar1.SmallChange = 0.1;
    
        // etc...
    }
    
    void scrollBar1_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
    {
        FteHolderText.Text = scrollBar1.Value.ToString();
    }
    

提交回复
热议问题