i was trying to update tickbar of slider but i couldnt update frequently ..its working only once .it is not reflecting the changed values for the next times .but the values were being passed but the drawingcontext is not being overidden.
this below code is working only once .
its hitting for the second time but the values were not being chnaged .
What I have tried:
this is xaml--> slider
<pre><Slider Height="27" x:Name="slider" TickPlacement="TopLeft" Margin="5,0,0,0" IsMoveToPointEnabled="True" Width="458" Template="{DynamicResource Slider}" Style="{DynamicResource Horizontal_Slider}">
this is my slider style
<wrbitmap:CustomTickBar x:Name="TopCustomTicker" Fill="{TemplateBinding Foreground}" Height="3" Margin="0,-15,0,0" Placement="Top" Grid.Row="0" Visibility="Visible"></wrbitmap:CustomTickBar>
<TickBar x:Name="BottomTick" Fill="White" SnapsToDevicePixels="True" Grid.Row="2" Placement="Top" Height="4" Margin="0,-35,0,0" Visibility="Visible" />
code behind
<pre> public class CustomTickBar : TickBar
{
DrawingGroup backingStore = new DrawingGroup();
DrawingVisual drawingVisual = new DrawingVisual();
public void ResetTimes(long ImageStartTime, double TickFrequency)
{
this.StartPlayerTime = ImageStartTime;
var drawingContext = backingStore.Open();
OnRender(drawingContext);
this.InvalidateVisual();
drawingContext.Close();
}
public static double Tickfrequency;
public long StartPlayerTime;
protected override void OnRender(System.Windows.Media.DrawingContext dc)
{
double num = this.Maximum - this.Minimum;
double y = this.ReservedSpace * 0.5;
FormattedText formattedText = null;
double x = 0;
for (double i = 0; i <= num; i += this.TickFrequency)
{
var time = TimeSpan.FromSeconds(StartPlayerTime);
var ti = TimeSpan.FromSeconds(i);
double t = (time + ti).TotalSeconds;
var T = TimeSpan.FromSeconds(t);
var TIME = T.Hours + ":" + T.Minutes;
formattedText = new FormattedText(TIME.ToString(), CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight,
new Typeface("Verdana"), 8, Brushes.White);
x += this.ActualWidth / (num / this.TickFrequency);
dc.DrawText(formattedText, new Point(x - 80, y));
}
}