Border radius on Entry Xamarin Forms PCL - c#

Is there a way to set a border radius on an Entry in Xamarin's XAML, or by using a custom renderer or something ?
Everything I've tried up to now has no effect, but for my application it would be really better if I had round borders.
Thank you in advance for your answer !
PS : I've checked this post but I've not found my answer there :)

I've posted this answer here too, but for convenience I'll just paste it below:
I'm not sure if there's something wrong with this approach or not, because it seems so simple but no one's suggesting it.
But I don't see why you can't just use a Frame with IsClippedToBounds set to true. That gives you a built-in corner radius, which you can then adjust as needed.
<Grid>
<Frame
CornerRadius ="20"
IsClippedToBounds="true">
<Editor />
</Frame>
</Grid>
I'm currently using this solution and it works for me.

I think you can use a grid with 1 row and 1 column
Inside the grid you can add your Entry and, for example, this control, in the same (the only) cell. You should have an Entry with rounded corners...
This is another useful control (XFShape). Create shapes content views from shared code for your mobile apps! For Android and iOS.

Related

c# W.P.F. image show tiff (just 1 page) blurry [duplicate]

I'm using some Images in my WPF applcation.
XAML:
<Image Name="ImageOrderedList"
Source="images/OrderedList.png"
ToolTip="Ordered List"
Margin="0,0,5,5"
Width="20"
Height="20"
SnapsToDevicePixels="True"
MouseUp="Image_MouseUp"
MouseEnter="Image_MouseEnter"
MouseLeave="Image_MouseLeave" />
But, they appear fuzzy.
Why doesn't that SnapsToDevicePixels="True" line prevent this problem?
You may want to consider trying a new property available now in WPF4. Leave the RenderOptions.BitmapScalingMode to HighQuality or just don't declare it.
NearestNeighbor worked for me except it led to jaggy bitmaps when zooming in on the application. It also didn't seem to fix any glitches where icons were sizing in weird ways.
On your root element (i.e. your main window) add this property: UseLayoutRounding="True".
A property previously only available in Silverlight has now fixed all Bitmap sizing woes. :)
Rather than using SnapsToDevicePixels, I instead used RenderOptions.BitmapScalingMode and they're now nice and crisp!
XAML:
<Image Name="ImageOrderedList"
Source="images/OrderedList.png"
ToolTip="Ordered List"
Margin="0,0,5,5"
Width="20"
Height="20"
RenderOptions.BitmapScalingMode="NearestNeighbor"
MouseUp="Image_MouseUp"
MouseEnter="Image_MouseEnter"
MouseLeave="Image_MouseLeave" />
+1 for Zack Peterson
I'm using .Net 3.5 sp1 and it looks like the most simple solution for a large number of fuzzy images.
It's not a big deal to specify RenderOptions in-place, but for 3rd-party components a style in app-level resource makes sense:
<Style TargetType="{x:Type Image}">
<Setter
Property="RenderOptions.BitmapScalingMode"
Value="NearestNeighbor" />
</Style>
Worked nicely when AvalonDock started to render blurry icons.
Using the UseLayoutRounding="True" on the root Window works in many cases but I encountered a problem when using the WPF Ribbon control. My application relies on Contextual Tabs that appear according to what the user is doing and when I set the UseLayoutRounding to True, the contextual tab would not show up and the RibbonButton's image neither. Also, the application freezes for many seconds and CPU fan starts to sing.
Using RenderOptions.BitmapScalingMode="NearestNeighbor" on my image corrected the image rendering issues (fuzzy and cropped image) and is fully compatible with the Ribbon Contextual Tabs usage.
RenderOptions.BitmapScalingMode="NearestNeighbor" works well most of the time. However, occasionally you'll get graphical glitches (in my case, 4 out of 5 images showed up fine, but the fifth had a slight distortion on the right edge). I fixed it my increasing the Image control's right margin by 1.
If that still doesn't fix it, try the Bitmap class control above that EugeneZ mentions. It's a replacement for the Image control and so far it's worked pretty well for me. See http://blogs.msdn.com/dwayneneed/archive/2007/10/05/blurry-bitmaps.aspx
use UseLayoutRounding=True to the top most element in your application
Make sure you save the image in the same DPI as your WPF application is working in, some image formats have this info stored as metadata. I don't know if this solves the problem but I've hade some problems because of this where images resized to 100% got bigger or smaller than expected.
Might be something similar.
I believe this is a bug (or at least it was). Check out this Microsoft support e-mail exchange page for some ideas to fix it.
I have found that the RenderOptions.BitmapScalingMode="NearestNeighbor" does not work for me. I'm using Windows XP x32 with DirectX 9.0c. As the actual rendering for WPF is done with DirectX, this could have an effect. I do have anti-aliasing turned on for XP with the following registry entries:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Avalon.Graphics]
"MaxMultisampleType"=dword:00000004
"EnableDebugControl"=dword:00000001
However, turning aa off with these settings has no effect on the images. I think this only effects 3D Viewports.
Finally, I found that the blurring occurs with the text of TextBlocks as well as images. And the blurring only happens for some text blocks and images, not all of them.
I have found that no combination of the suggested workarounds would cure my seemingly random blurry image problem. I like many others cannot upgrade to .net 4 in order to use the UseLayoutRendering property.
What I have found to work:
Ensure your [original] image dimensions are multiples of 2. This seems to prevent some of the funky image scaling problems.
Sometimes I have also found that adjusting margins on images by a pixel or 2 can prevent the problem.
My first thought, reading the question, was you were blowing up the image too much, but that does not appear to be the case looking at the image you have of the app.
Second thought is color palette, but with black as one of the colors that is not rendering correctly, this is not as likely.
If you can fully rule out the two above, I am currently stumped.
As an experiment, you can try other graphics formats, but PNG should be fine. I will have to think it through some more to come up with a better answer.
I've tried to use the RenderOptions.BitmapScalingMode=HighQuality, seems like is causes some problems in Windows 8.1, so what i did was to run them through the tool called PngOut.exe
http://advsys.net/ken/utils.htm
Which reduces the header of the png, and also reduces the size, but without changing the image quality.
And now all my images are perfect! :-)

Syncfusion Range slider space

I am trying to add the syncfusion range slider in my xamarin form application.
everything is okay but there is a small problem.
there is a blank space in the top and bottom side of the range slider.
i don't know from where it's coming.
i just placed the slider inside a stacklayout that's it.
<range:SfRangeSlider x:Name="rangeslider_salary" Minimum="1000" Maximum="300000" RangeStart="3000" RangeEnd="100000" TickPlacement="None" ShowRange="True" ShowValueLabel="False" Orientation="Horizontal" LabelColor="#ED4350" KnobColor="#ED4350" TrackSelectionColor="#ED4350" ToolTipTextColor="#ED4350" RangeChanging="Rangeslider_salary_RangeChanging"/>
Thank you!
We have analysed your requirement and have created a simple sample with SfRangeSlider Control. Please have the sample from the below link.
Sample Link: RangeSlider
Please check the sample and let us know if you have any concern.
Regards,
Rabhia Beham K[Syncfusion].

Editing UINavigationBar translucence adds padding on bottom

I've been developing with Xamarin and iOS for about two weeks now, and currently I'm attempting to figure out why a strange bug is happening. I've looked all over Google and even SO, but can't find an answer...one that works, anyways. As the title says, whenever I change the Translucent boolean property of my NavigationController.NavigationBar, extra padding is added for seemingly no reason. This can be seen in the image below:
The line of code I use for this is this.NavigationController.NavigationBar.Translucent = false; and without that line, the application looks like this:
Other than that line, the NavigationController.NavigationBar is unedited. So, does anyone know what I'm doing wrong? Any help would be much appreciated...thanks SO!
It depends on the way how you construct your views and their containments.
Make sure that EdgesForExtendedLayout (Apple Docu) has the right value. I would suggest UIRectEdge.All.
In the case you are using a scrollView als check the automaticallyAdjustsScrollViewInsets property.
So, I actually figured out through posting on the Xamarin Forums and browsing through their documentation that the UINavigationBar.Translucent property adjusts the view if you turn it off such that all of the screen's contents are visible beneath the now-opaque UINavigationBar. I was simply placing the UI elements with unnecessarily large Y-values because I was unaware of the screen change after .Translucent = false;
I changed the .Frame = new CGRect(x, y, w, h) properties of each UI element with respect to 0 being right below the navigation bar, not underneath it.

WPF InkCanvas: how to disable antialiasing

I'm using an InkCanvas in my project and I noticed that whenever I draw something, the stroke is very sharp, and once I release the mouse button it becomes blurry.
Is there any way I can keep the stroke identical to what it looks like as I'm drawing it?
Right now I'm going through the array I get from the image and I remove any pixel that doesn't perfectly match Color.Red (i.e., ARGB: 255,255,0,0)... and I'm sure there's a smarter way to do this!
Thanks in advance.
Ok. I found an answer!
Sources:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d95c6b91-2a68-455b-b9d4-021bd5c96029/how-to-disable-smoothing-for-stroke-?forum=wpf
Rendering sharp lines in WPF
I just tried to add RenderOptions.EdgeMode="Aliased" directly into XAML (the property doesn't show up in the Properties window, when selecting the InkCanvas) and it works.
Basically from this:
<InkCanvas x:Name="myInkCanvas" MoveEnabled="False" ...>
To:
<InkCanvas x:Name="myInkCanvas" MoveEnabled="False" RenderOptions.EdgeMode = "Aliased" ...>
On MouseUp, the stroke stille "moves" a bit, but the stroke itself is perfectly sharp!

How would you create stackable rectangles in Xamarin C# for iOS?

I have a UIView that I want to fill with multiple rectangles stacked on top of each other horizontally at 100% width. They all need to have their own name and need to work for any iOS device regardless of size.
Here's a simple diagram showing what I would like to accomplish:
With Xamarin.Forms, this is achieved by using a StackLayout.
http://iosapi.xamarin.com/?link=T%3aXamarin.Forms.StackLayout
I find it difficult to control the exact sizes of StackLayouts if you're not sure of the size of your content.
If i need something to stay fixed size, i use Grids:
http://iosapi.xamarin.com/?link=T%3aXamarin.Forms.Grid
I would recommend XibFree for this:
http://www.toptensoftware.com/xibfree/
They have a few great examples which covers these case as well:
http://www.toptensoftware.com/xibfree/example_2
http://www.toptensoftware.com/xibfree/example_1
If you would need any more help with XibFree feel free to ask anything in comment :)

Categories

Resources