Styling Rectangle or Path in windows 8 - windows-8

Is it possible to style a rectangle or path like this(Image given "Cylindrical Image" w.o the line behind).You can notice a cylindrical 3D effect in that image. In my application i cant apply a default background image to my control. I need to use the color that is given by the use. I tried to create this in blend. But unfortunately I can't get that 3D effect. Also i can't find a method to give gradient effect vertical plane. I think someone with expertise in Blend and design can help me.
I found something similar to my question here in Stackoverflow But that solution didn't solve my issue.
Thanks in advance.
Stephan

You can accomplish this by using a LinearGradientBrush.
<Rectangle Width="100">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FF2F3243" Offset="1"/>
<GradientStop Color="#FF5B5E6D" Offset="0.5"/>
<GradientStop Color="#FF2F3243"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>

Related

Centered Shadow Using Uno.Platform ElevatedView

I can't center the shadow provided by <toolkit:ElevatedView> around the contained object. By default the shadow falls to the lower right corner. I've tried shifting with margins as well as RenderTransform, but can't find a good way to move the shadow.
What I have:
<toolkit:ElevatedView x:Name="Shadow1" Elevation="25" ShadowColor="Gray" CornerRadius="20" Background="Transparent">
<Grid>
<Grid.RenderTransform>
<TranslateTransform X="20" Y="20"/>
</Grid.RenderTransform>
...stuff
</Grid>
</toolkit:ElevatedView>
This kind of works but screws up the grid corner radius because it is being shifted beyond its max width. Is there a way to simply move the shadow location instead of trying to shift the content inside the shadow?
As of Uno Platform 3.11, the ElevatedView Control does not support changing the orientation of the shadow, only the elevation.
You may want to open an enhancement request on the Uno Platform GitHub repository.

Create Circular Image Xaml

In windows phone 8 I want to put an Image in a circle. Is there a container like grid which have a circular form? I know that there is ellipse bit it is not a container
Here is how I do it.
<Ellipse Width="100"
Height="100">
<Ellipse.Fill>
<ImageBrush>
<ImageBrush.ImageSource>
<BitmapImage UriSource="/YourImage.png" />
</ImageBrush.ImageSource>
</ImageBrush>
</Ellipse.Fill>
</Ellipse>
As a best practice, consider setting DecodePixelWidth and DecodePixelHeight to the same size as your ellipse.
Another option to mleroy's answer (since if I remember right WP is based on silverlight and I often run into a lack of brush availability to do stuff like that.) You could do this using the Clip property.
For example;
<Image
Source="blah\yourpicture.jpg"
Width="100" Height="100">
<Image.Clip>
<EllipseGeometry
RadiusX="100"
RadiusY="100"
Center="100,100"/>
</Image.Clip>
</Image>
Hope this helps, cheers
Edit Addition: You could also bind your radius X/Y to the width/height of the image for more flexibility on dynamic sized images.

How can I use a non-SolidColor brush for WinRT xaml TextBox foreground color?

I'm trying to style a TextBox such that the text is rendered with an Image brush, but I can't seem to get it to work.
Given, the following snippet, I am able to set the text to render with a solid color brush. However, if I instead try to use either of the commented out brushes (LinearGrad or ImageBrush), it just renders as solid black text.
<TextBox Text="test" Background="{x:Null}" FontSize="64">
<TextBox.Foreground>
<SolidColorBrush Color="Plum"/>
<!--<LinearGradientBrush StartPoint="0 0" EndPoint="1 0">
<GradientStop Color="White"/>
<GradientStop Color="Black" Offset="1"/>
</LinearGradientBrush>-->
<!--<ImageBrush ImageSource="ms-appx:/Assets/Texture.png"/>-->
</TextBox.Foreground>
</TextBox>
I can do the same thing to style a TextBlock, but it doesn't seem to work on a TextBox. Is there something I'm missing? The documentation makes no mention about any limitations or exceptions: MSDN Docs
To be clear, this is NOT a WPF question. I know this works in WPF, this is a Windows 8 App (WinRT).
Seems like it might be an undocumented unsupported scenario based on my testing. If you really need to do it though - you could create a custom template of the TextBox that displays a TextBlock when the control is not in use and template-bind the TextBlock.Foreground and other properties to the respective TextBox properties.

Slider overflow

I have popup-like border in my page. There is slider inside the popup. The slider has range from 0 to 100, but when I slide it to the right edge I get somewhere near to vlaue 93. Slider is full but its maximum is 100. It seems that slider overflowed the parent container. I tried to use all combinations of margins and static widths, but without success. Can anyone tell me what I am supposed to set, to get it work?
Here is fragment of code:
<Grid x:Name="LayoutRoot" >
...
<Border VerticalAlignment="Center" Margin="24,0" Visibility="{Binding ...}">
<StackPanel>
<TextBlock Text="choose desired position" />
<Slider x:Name="sldGoto" Maximum="100" SmallChange="1" LargeChange="10" Value="93"/>
</StackPanel>
</Border>
</Grid>
With this code (value of slider set to 93) is slider full. What's wrong?
This is a known bug in the current release when using Slider on Windows Phone 7 with the standard control template. I recommend using the approach you found on Dave's blog for now.
Well I just find article with nice Slider ControlTemplate that just works.
I would still appreciate if anyone could confirm this behavior or told me what I did wrong.
Thanks

Is there any way to do a Drop Shadow effect in XAML on a TextBlock?

I have a XAML TextBlock that I would like to render as a drop shadow. That is a white layer of text on top of a black layer. I'm doing this to make the text stand. Currently I have two TextBlocks offset to the right and below by two pixels. The top layer is white and the bottom layer is black.
Is there a simple way to do this in XAML? If so can you please provide an example?
Bitmap effects are deprecated. Use the new GPU-accelerated DropShadowEffect instead.
<TextBlock>
<TextBlock.Effect>
<DropShadowEffect />
</TextBlock.Effect>
Drop.
</TextBlock>
<TextBlock
Text="Shadow Text"
Foreground="Teal">
<TextBlock.BitmapEffect>
<DropShadowBitmapEffect
ShadowDepth="4"
Direction="330"
Color="Black"
Opacity="0.5"
Softness="0.25" />
</TextBlock.BitmapEffect>
</TextBlock>
There are plenty of other examples on MSDN