开发者

Editing a Slider's Thumb Template to be an Image Windows Phone 7

So I've been looking up a lot of "custom sliders" through google from all the major sources such as windowsphonegeek, msdn etc. But for some reason I can't seem to figure out how to make the thumb of the slider an image (a png for example).

开发者_JAVA百科

Here is a little bit of xaml where the problem lies

    <Control.Template Name="ThumbTemplate1" TargetType="Thumb">
        <Image Source="myImage.png" Height="48" Width="48" />
    </Control.Template>

At the moment this will not show any thumb since it isn't loading the image properly.


     <Style x:Key="ThumbStyle1" TargetType="Thumb">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Thumb">
                    <Grid Margin="0,-15,-70,-8">
                        <Ellipse Fill="{Binding ThumbImage}" Stretch="UniformToFill"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

Its important to set the fill the ellipse/rectangle etc this way if you want the binding for the image since binding image brushes is very problematic, this take care of some of the hassle


Have you checked the path to the image (by diplaying it outside your template)?

Ensure the image file has a build action of "Content" (the default is "Resource") and ensure you start the name with a "/".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜