c# - How to Dynamically Populate Slider and Get Value -


I have a declared slider in XML, which I want to populate with the values ​​based on a certain selection of the user. One page is dynamically populated with many unique control items, called phototamlet, in which there are many properties, once to determine which photobatam was selected, I used to adjust some properties I want to show the slider to I have declared a single slider in XAM, and I am trying to use this same slider over and over again. Depending on the selection of a user, the slider will be populated with different minimum and maximum values, and the last value of the user's selection will apply to some settings. To illustrate this I have the following

XAML

  & lt; Slider x: name = "sl" visibility = "collapsed" />  

XAML.CS

  zero editable Ellipse_Tap (Object Sender, System.Windows.Input.GestureEventArgs e) {If (Sender! = Faucet) { DependencyObject Tape Element = E.OriginalSource as UIElement; // Find the Tippit Phototnm Phototamine I = this.FindParentOfType & lt; Phototabal & gt; (Tape element) parent UI elements; If (i! = Null) {BuildControl (I); } P.IsOpen = true; FilterPagePivot.IsHitTestVisible = false; }} Private Wide BuildControl (Phototabal P) {Switch (PNN) {Case "1": SL = New Slider {Minimum = 1, Max = 256, Visibility = System.indow. Visibility Visual}; break; Case "2": sl = New slider {min = 1, max = 10, visibility = system. Windows Visibility Visual}; break; ...}}  

Primarily, the slider in XAML does not take on the newly defined properties, and it also does not appear. Note that I am capturing the changes to the slider's value change event.

Creates new examples of posted code slider - you should use existing slider instance instead , That is:

  switch (p.NName) {case "1": sl.Minimum = 1; Sl.Maximum = 256; Sl.Visibility = System.Windows.Visibility.Visible; break;  

Note: I believe that you are referred to as Generated XAML Members (whom you referred to as "sl" as their x: name attribute) Only keep reading.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -