How to create a custom button for Windows Store app? - c#

I want to make a custom button in shape of a picture with C# for a Windows Store App?
Is there a way to do that from xaml? So far I've made a button and assigned a circle as a background image, but the problem is that even if I click outside the image the button works.
Also I do not believe that Image class has an event for click unfortunately.

I just recently implemented the WinRT XAML toolkit and it works wonder for me. It has an imagebutton control that might do what you want to do. http://winrtxamltoolkit.codeplex.com/

With the help of google: Walkthrough: Create a Button by Using XAML
You should have a look into Expression Blend. You can do all manualy in the XAML-Code but Blend is a huge help if you like to customize your project look and feel. Look at the MSDN-Examples.

Related

Dynamic form with resizing in C# .net

As a learning project in C# .net I am re-creating a Gnome 3 plugin for seeing who of the streamers you follow on Twitch is live. I have the settings form done, I am now working on the interface that is viewed from a click on the taskbar.
This is a rough image of what I want the interface to look like. When two or more streamers are live the interface would add another block and resize the form vertically similar to the menu for selecting a Wifi network in Windows.
What would be the best way for me to complete this?
My current thought is to maybe create a custom control and just place those inside a FlowLayoutPanel with some kind of code to change the vertical size of the form to match the added entries. Maybe this can be done without a custom control and be done with code inside a FlowLayoutPanel? I'm not too sure.
Ideally I would also have a click event in the panel for each streamer so I could then open a browser to their channel. A slight highlight would also be a plus (maybe change the background colour based on mouse hover).
Thanks in advance for any suggestions!

Define image source after button click Windows 10 UWP, XAML C#

I'm a new developer trying to learn to develop for Windows 10 UWP and I've been struggling with the basics for days. I'm just trying to figure out how to change XAML properties using C#, in particular I'd like to change the source of an image so that clicking a button will change the image displayed. I'm used to javascript and jQuery which make this process absolutely painless ($("#elementID").attr("src", "Images/NameOfFile.PNG");). How do I do this for a UWP app? It seems like data binding is similar but I'm having a lot of difficulty understanding it and can't imagine that doing something so simple would have to be so difficult. Can you help me with this? Thanks!
The most simple way (without data binding) is to directly access the Image control in code behind. Give the control a name
<Image x:Name="image"/>
and set its Source property in code behind, e.g. in a Button Click handler
image.Source = new BitmapImage(new Uri("ms-appx:///Images/NameOfFile.png"));
where NameOfFile.png must be added to a folder named Images in your Visual Studio project.
See class Uri for details about the ms-appx:// scheme.

Create a popover-like control in C# WinForms?

So, one of my favorite things about iOS/ObjC in general is the "popover" control.
I am building an app in C# WinForms that would benefit greatly from this type of control- anyone have any ideas on how I might be able to emulate this type of look?
For reference, here's an example screenshot of what I'm talking about http://i.imgur.com/IzbbzrA.png
Thanks for any ideas!
You can create a simple popup control by following the articles linked below
Simple Popup Control
I don't think such a control exists in .Net. What I would do from this point if I were you is try to making one using a customized windows form on top of it. Play with the Mouse Hover events of the control and make the form appear for a short time. Make it without borders. With a little imagination you can have your own version of the PopOver.

How can I make the mainMenuStrip look glossy in a Windows forms application

I'm trying to make a nice looking UI with Windows Forms but the main problem I have is that the MenuStrip in Windows Forms looks flat. In WPF everything is shiny and pops out, how can I make it so that it looks like that? I tried using a gradient background image but the buttons stayed as blue rectangles. I am also willing to use an alternative control. Any ideas?
I forgot to mention, regarding alternative controls I am looking for something free and open-source.
My personal suggestion would be that you move from menustrips to "Office-like" menus / ribbons.
Please go through the following links / search through these sites
for more custom controls for winforms
Code Project
http://www.codeproject.com/Articles/12204/Flat-style-menu-bar-and-popup-menu-control-for-Win
Windows Ribbon for WinForms (Part 1-21)
http://www.codeproject.com/Articles/62412/Windows-Ribbon-for-WinForms-Part-1-Introduction
Code Plex
http://ribbon.codeplex.com
http://fluent.codeplex.com
http://windowsribbon.codeplex.com

Creating a round button

In my wp7 app, I use C# to create user interface. I want to create a round button in C# not in xaml. is it possible to do that only in C# (not with the help of xaml) ? if yes, how to do this? and also please explain how to change a style of a button or any other control by using C# code?
Yes you can but don't know why you'd want to. Much easier to do with styles. Even easier to use one from an existing toolkit.
There is a round button in the Coding4Fun Phone Toolkit.
Get it via NuGet or download it here

Categories