RenDishen
RenDishen

Reputation: 938

Slider size changing

I am faced a problem with sizing of slider in WinRT project. I have simple default slider in my xaml, like this:

        <Slider x:Name="slider1" 
            HorizontalAlignment="Stretch"
            VerticalAlignment="Top"
            BorderBrush="White" 
            BorderThickness="5"/>

This slider have width along all page and when this page changing its size, slider must change his size too. But here is the problem. If i am set slider's value to maximum point and drag app window to portrait state, size of slider doesn't changing on the view. It become to actual size only after manipulation. I have already tried to monitor data, when fires up SizeChanged event and slider takes correct NewSize, but doesn't changing its view. On the screen below you can see what i talking about. Slider's body goes out of the window in portrait state(or any other).

enter image description here

So is it bug of defaul control and how i can workaround this issue?

Upvotes: 1

Views: 791

Answers (1)

RenDishen
RenDishen

Reputation: 938

I figured out some workaround how to solve this problem, but solution is pretty ugly.

private void Slider1_OnSizeChanged(object sender, SizeChangedEventArgs e)
{
    var value = this.slider1.Value;
    this.slider1.Value = 0;

    this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    {
        this.slider1.Value = value;
    });
}

If someone will come up with something better, let me know please.

Upvotes: 3

Related Questions