background image not showing for edit text from #drawable - c#

I have created android app using xamarin native and put some pics in res/drawable but when I want to use that images in xml they don't show up neither in designer view nor in intellisense.
<EditText
android:layout_width="333dp"
android:layout_height="156dp"
**android:background="#drawable/emailbg"**
android:hint="Password"
android:password="true"
android:textSize="20dp"
android:layout_marginTop="280dp"
android:paddingStart="100dp"
android:paddingBottom="25dp"
android:textColorHint="#a3a3a3"
android:id="#+id/pass_et"
/>

Please mark sure that you are putting the image under drawable folder and the Build Action is AndroidResource.
If the image does not show up, try to close Visual-Studio and open again.
Here is a screenshot I did and it works well on my side. Feel free to ask me any question.

Related

Xamarin.Android Material Design Icons

A bit of context:
I was looking into the Material Design Support Library for Xamarin and found this article about various controls from this library.
I tried to reproduce the Toolbar from the last example (for now I'm not even thinking about implementing the whole hamburger navigation example, just the toolbar with the button). I set it up, created MyTheme with my colors, added the fixes for style-v21 and so on. Everything works well so far, though the <include ... /> node throws a warning that it's not a recognized child for RelativeLayout. Still, it's building correctly so I can deal with it for the most part.
The problem:
Here's where my problem starts:
...
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.main_layout);
var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
SetSupportActionBar (toolbar);
//Enable support action bar to display hamburger
SupportActionBar.SetHomeAsUpIndicator (Resource.Drawable.ic_menu);
SupportActionBar.SetDisplayHomeAsUpEnabled (true);
...
With the SupportActionBar set up like that, it doesn't display the button. Also, the ic_menu drawable seems to be missing. In fact, there aren't any that start with ic_, only abc_.
Am I missing something here?
Cheers!
Go to https://material.io/icons/ and download menu icon and then add that icon to the drawable folder and then replace ic_menu in your code with the image name.
NOTE: Do not add image extension name like .jpg,.png with image name

Cant get rid off JumpTask item

I was just playing around with a JumpList in WPA app. I have added this code to my App.xaml:
<JumpList.JumpList>
<JumpList ShowRecentCategory="False" ShowFrequentCategory="False">
<JumpTask Title="New Note" Description="Create new note"
Arguments="/new" CustomCategory="Actions"/>
</JumpList>
</JumpList.JumpList>
Then i decided not to include that functionality in my app, so i removed those lines of code, but the item is still on the JumpList when i right click the taskbar icon.
I found solution that points to delete files from %APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations\, but it didn't help.
Cleaning or rebuilding project didn't help.
As discussed in the comments, you need to leave an empty <JumpList> in your application and run it once. You should then be able to remove the <JumpList> from your markup completely if required.
If the <JumpList> element isn't present, the code to update the jump list never executes, and Windows continues to use the previous jump list.

Change Background image in WPF using C# [duplicate]

This question already has answers here:
Change WPF window background image in C# code
(7 answers)
Closed 7 years ago.
I'd like to change the background image of my WPF application by a button. I know how to do it using WindowsForms, but in WPF I failed.
I found a solution already, but that solution would copy my background images to the output folder next to the Application.exe
This is not really a solution that I desire. I would like to have the images stored inside my application.
Can somebody explain me detailed what I need to do [how to add the images to the program, especially the resource-properties, how to access them in C#....]. It seems like I am too stupid to set it up correctly :P
Thanks in advance
Firstly, add a Folder to your Solution (Right click -> Add -> Folder), name it something like "Resources" or something useful.
Then, simply add your desired image to the folder (Right click on folder -> Add -> Existing item).
Once it's been added, if you click on the image and open the Properties window (Alt+Enter), you'll see the Build Action is set to Resource and the Copy to Output Directory is set to Do not copy.
You can reference the image in C# using the following code:
this.Background = new BitmapImage(new Uri(#"pack://application:,,,/YourApp;component/YourFolder/YourImage.png"));
Or in XAML:
<Image Source="pack://application:,,,/YourApp;component/YourFolder/YourImage.png" ... />
Or:
<Image Source="/YourApp;component/YourFolder/YourImage.png" ... />
Try this:
this.Background = new ImageBrush(new BitmapImage(new Uri(#"pack://application:,,,/Yourapp;component/yourimage.png")));

Set an image in UI

Im using .net c# MVC3 Model. I need to show a gif called loading when I click save on the page. I used <img src="sourcepath" alt="loading" style="display:none"/> and trying to display it whenever user clicks save button using jquery. I have stored the image temporarily in views folder. Unfortunately, i could not see image on the screen. I can see its division with a small red cross cancel button.
Pls Help
If you're seeing the broken image icon, it means your src "sourcepath" is wrong. You would normally put static content in the Content folder of your site, and access it using /Content/imagename.jpg or /Content/Images/imagename.jpg or similar.
Try to use the search, here you can find an solution the show an spinner when doing ajax requests:
How to show loading spinner in jQuery?

How do I cast an icon from a resource file to an image for use on a button?

I'm trying to use an icon that I've added as a resource as the image on a button. I know it's possible because I can do it in other projects through the designer. However, I'm trying to do this with code. I added the icon as a resource to my project by following the steps in the accepted answer to this question. The resource is named CancelButtonIcon.
Now, I'm trying to add that icon as the image on a standard button with this code:
this.CancelButton.Image = (System.Drawing.Image)Properties.Resources.CancelButtonIcon;
However, I get an error message:
Cannot convert type 'System.Drawing.Icon' to 'System.Drawing.Image'
In the code that Visual Studio automatically generates when I use the designer, it looks like this:
((System.Drawing.Image)(resources.GetObject("SaveButton.Image")));
which results from manually adding a resource through the Properties window. How can I convert this icon resource to an image so it can be used on the button? Adding it through the designer is not an option (this button is created programmatically and thus isn't present in the designer).
You can use the Icon.ToBitmap method for this purpose. Note that a Bitmap is an Image.
CancelButton.Image = Properties.Resources.CancelButtonIcon.ToBitmap();
Not sure why, but any time I tried using the accepted answer's approach, the .ToBitmap() call was giving me array index out of bounds exceptions. I solved this by doing it this way instead:
System.Drawing.Icon.FromHandle(Properties.Resources.CancelButtonIcon.Handle).ToBitmap();

Categories