I have two questions that you hopefully can help me with:
I'm struggeling with BorderBrush property and I need to be able to set it in code. It works if I do it like below but I need to give it a haxadecimal value (#ffcccccc) and can't figure out how to do it.
datePicker1.BorderBrush = (SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"];
I have a datePicker and would like to give it a border color and set the background in the same way as my TextBox fields but I'm failing. What is the trick in modifying this control? I would prefer if I didn't have to use Blend.
Use Color.FromArgb
You have to customize the DatePicker template. This is of course, easiest done using Expression Blend. If you're clueless about XAML, I'll recommend you don't do custom control styles unless you have studied the subject more.
Related
I have a problem to show my object field Description on Cross Platform Label . Description has many hashtag, that need to be clicked and open another page. Here is my example :
"I have some #issues that need to be #solved maybe Xamarin#Support can help me."
That is my description, and i want to put it on Label. How can i set those hashtag (#issues, #solved, #Support) to be clickable?
One option is to use a WebView and use simple HTML / CSS. This would give you the most flexibility and in some cases is the simplest.
Another option would be to write custom renderers. There are plenty of answers out there on how to do this natively but as a starting point.
On Android you need to use a TextView with autoLink="web".
On iOS, a UILabel should allow you to do this.
You can change color, ForegroundColor, FontAttributes of the hashtags by using Span in the label. Sadly, Span doesn't have GestureRecognizers.
I suggest you to stack multiple labels and add TapGestureRecognizer on the label with hashtags.
I'm creating a simple GUI using Powershell and Windows Forms for a set of scripts I have written.
I've generated a bunch of buttons in the GUI and I'm currently in the process of adding styles to my buttons.
$Button1 = New-Object System.Windows.Forms.Button
Is there anyway to set the below set of lines as a global/default setting of sorts for all buttons?
$Button1.Cursor = [System.Windows.Forms.Cursors]::Hand
$Button1.BackColor = '#CCCC99'
$Button1.Font = New-Object System.Drawing.Font("Verdana",10,[System.Drawing.FontStyle]::Bold)
To give you an idea, what I'm doing now is adding the block of text for every button.
$Button1.BackColor = '#CCCC99'
$Button2.BackColor = '#CCCC99'
$Button3.BackColor = '#CCCC99'
etc...
I'm pretty sure there's a better and more efficient way to do this. Can anyone point me to the right direction?
I expect all buttons to look pretty much the same.
Thanks in advance.
You could loop through all of the buttons after they have been created and set their properties, like TheMadTechnician suggests…
But there is a better way. Think object-oriented programming. You have a Button class, and you want to change its default properties. In fact, you want all of your buttons to have those new properties. So really, what you want is a custom control that is like a button but slightly different.
Well, what do you know? There's a linguistic way to express that:
public class MyBeautifulButton : System.Windows.Forms.Button
{
public MyBeautifulButton()
{
// Set default properties here...
}
}
You can even go one fancier and override the specific properties, setting the appropriate attributes, to change their default values.
Then, instead of creating System.Windows.Forms.Button objects in your PowerShell code, you will create MyBeautifulButton objects.
Although I must say that I don't think the result will be terribly beautiful. The BackColor property of a button is one of those that I don't think should have ever been provided. Button controls are designed to be drawn using the system theme, which specifies the colors for you. It also allows the users to customize the colors as desired. Application-specified colors usually result in a visually jarring and downright ugly UI. Don't let your app stick out like a sore thumb. Buttons are utility controls. Consistency is key. Remember that GUI applications are not web pages.
Why not just apply that to all buttons after you add them to the form? Something along the lines of:
$MyForm.Controls | Where{$_.GetType().Name -eq "Button"} | ForEach{$_.BackColor = '#CCCC99'}
So, I am having an odd behavior. Maybe it's intentional, but I can't seem to figure it out. I haven't worked much in Blend and prior to this been mostly coding XAML manually. I am trying create a custom template for a MenuItem and when it's being moused over, I need to turn its background a specific color. So, I'm doing this MouseEnter event trigger on the OuterBorder. When I try to change the color, no matter what color I set it as, it turns black immediately. This happens on all of the control in template, regardless which one I choose. So, I have to manually go into XAML and change it to the specific color.
After I set it to a specific color within the XAML code, if I try to change it through the Properties menu, it'll turn back to that color I set in the code.
If I export template into a ResourceDictionary, it lets me edit everything as if nothing wrong is occurring, but when the template is applied, the default background of the MenuItem control turns black.
By the way, this is Blend for Visual Studio 2013.
Any ideas what's going on?
What I ended up doing was not creating a separate even trigger and instead edited the template's existent triggers. Which worked great. My only concern is that the default one did not do fill, so I fail to see how there was a conflict between the two. Not sure if anyone knows?
Figured it out. Silly me. I was trying to change background that didn't exist. So, it had to create the background for the storyboard, and thus was setting it as the default black. What I did was create a background and set it's opacity to 0% and then change that instead. Worked as intended.
Is it possible to localize MS Chart Control's print preview form? If so, then how?
.net4/c#/winforms/vs2010
Good question. It seems that they did some custom dialog and forgot to localize it. I might be wrong but it appears that the only way would be to create your own dialog similar to .Net's and draw the chart on the CustomControl's surface using PrintPaint() method.
Sounds like a lot of work but it is actually fairly easy. The only problem I can think of is how to make sure that WYSIWYG :|
I feel kind of silly asking this question as it seems really simple, but how do I create a text box that I can type in instructions and stuff like that. I don't need the user to be able to change it, it is just to give instructions. I tried the label, but it only allows one line. I need something that can allow about a paragraph or so. Similar to the box in an installer that describes what the program does. What did I miss?
You can use a label but set its AutoSize property to false. This allows you to size the label as you wish and it will automatically wrap the text to fit.
You can also anchor the label to the parent form to have it automatically resize and reflow the text if the user resizes the parent form.
You want a text box, but set its Read Only property to TRUE, and maybe Enabled to FALSE