1 Replies - 11948 Views - Last Post: 19 August 2012 - 08:35 PM

#1 d.buckner  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 04-December 08

slider control smallchange not working

Posted 05 August 2012 - 11:42 AM

I am trying to get a slider to update a textbox, I have the largechange, and smallchange properties set. the largechage is working as it should. The smallchange is set to 1 as I want to step by 1. The output to the textbox on the smallchange is not a whole number as it should be. (2.244 for example).


XAML:
<Slider 
				x:Name="AngleSlider" 
				Margin="19,279,24,278" 
				Maximum="60" 
				SmallChange="1"
				LargeChange="10"
				/>
<TextBox 			
			x:Name="txtAngle" 
			Margin="92,194,0,0" 		
			InputScope="Number" 
			HorizontalAlignment="Left" 
			Width="85" FontSize="21" 
			Height="85" 
			VerticalAlignment="Top" 
			d:LayoutOverrides="Height"
			Text="{Binding ElementName=AngleSlider, Path=Value, Mode=TwoWay}" 			
			/>




I have tried other suggestions I have found to round the number created by the slider in a ValueChaged event handler, this is not working either.

private void AngleSlider_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<double> e)
        {
            AngleSlider.Value = Math.Round(e.NewValue);
        }


This post has been edited by d.buckner: 05 August 2012 - 11:50 AM


Is This A Good Question/Topic? 0
  • +

Replies To: slider control smallchange not working

#2 jase81  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 120
  • Joined: 02-March 09

Re: slider control smallchange not working

Posted 19 August 2012 - 08:35 PM

<TextBox 			
			x:Name="txtAngle" 
			Margin="92,194,0,0" 		
			InputScope="Number" 
			HorizontalAlignment="Left" 
			Width="85" FontSize="21" 
			Height="85" 
			VerticalAlignment="Top" 
			d:LayoutOverrides="Height"			
			>
    <TextBlock.Text>
        <Binding ElementName=AngleSlider, Path=Value, Mode=TwoWay">
            <Binding.StringFormat>{0:0}</Binding.StringFormat>
        </Binding>
    </TextBlock.Text>
</TextBlock>




Just play with the string format. I needed this for a distance measurement in units (metres) so my code was <Binding.StringFormat>{0:0}m</Binding.StringFormat>

Hope it helps
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1