I have managed to style a button such that there is a the background I wanted (Normal). However, I want to create an OuterGlowBitmapEffect on the content. Also, when I modify the style, it reverts to the default for MouseOver, Pressed, and HasFocus.
Here is the image of what I want, how could you do this using WPF Styles
http://tinypic.com/r/2s9ybfs/5
Without seeing your code I can't say for sure, but you need to add the "OuterGlowBitmapEffect" to the MouseOver, Pressed and HasFocus styles as well.
All these states come as a package and need to be modified in concert.
If you can, get hold of Expression Blend. This has options for creating templates and styles from existing ones and then for modifying the individual components of each aspect of the style.
Related
I've been trying to create a toggle button with a "simple" bevel effect for my WPF Window. At first I've tried to apply the BevelBitmapEffect but apparently it is not deprecated and there are no visual changes when applied.
I've have tried many other "tweaks" with no success.
The kind of button I'm going for is something like this:
Edit: I was able to create this effect by having two pictures (unpressed and pressed). Still, if anyone knows how to do this without any external resources that would be great.
You have two options for this,
Create a Style for the ToggleButton that gives the desired look, this page has an example of a simple style for a toggle button.
Make a toggle button custom control, which is the same idea but can be a bit simpler if you need to use the same style in multiple places or applications.
I make my own style for datagrid, I had changed every thing but there's a small part of datagrid make me crazy, because I can't change color for this part. I don't know the name of this part, as showing in the image :
How can I change color it?
It's not so clear from your image, but if that part is part of the ScrollBar then you can add a Style without defining an x:Key for it into your DataGrid.Resources section. That way, it can be implicitly applied to the ScrollBar parts. You can start with the default Style and then adjust it for your needs. You can find the default Style in the ScrollBar Styles and Templates page on MSDN. There is quite a lot of it so you'll have to do some experimentation with it.
UPDATE >>>
If you are talking about the Buttons that you can click to select the row, I believe that that part is called the row header. You can add a Style for that using the RowHeaderStyle property. Please see the WPF override DataGrid RowHeader template and manage to select rows still post for help with that.
Alternatively, I believe that you can hide it altogether by setting the DataGrid.RowHeaderWidth property to 0.
I want a button that
Displays an image with NO border, NO background, NO text
If I tab into the imagebutton, THEN it shows the background and border
Also if I hover over it, it shows the background and border
I've searched and I've tried so many different things, but nothing it exactly what I want. I've tried setting various properties on the button to make the background and border transparent, but it still shows up. I've tried a style with a custom control template. I'd rather not have to completely reinvent all the triggers etc to get the button to render on mouse over. The biggest problem with custom control template is that then I loose all existing functionality and I'm basically building a new control from the ground up.
Here is another link that came closest to what I wanted but it doesn't properly work for me.
How do you completely remove the button border in wpf? - BUT.... for some reason the hover effect gets stuck. One I mouse over the image and the button border draws, it stays stuck on until I click somewhere else.
Actually, you will want to override the control template. You're not "losing" any functionality (aside from the UI triggers).
Original/Default Template -- This is a good starting point... copy/paste that into you're XAML (wherever you want to style this button... ie Button resources, UserControl/Window resources, App Resources?). From there make your adjustments.
Another easy way is to use Expression Blend. You can easily create a new template based on the existing template, and the styling/authoring tools it provides are much better than hand-coding XAML (unless you're good at doing that).
As far as displaying an image instead of text, just set the image as the content. A Button is a type of ContentControl which means that it can house any type of content (Object).
I have a datagrid, and certain columns need to contain text that is linked to a detail window. So, in order to make it a bit easier on myself, I created a UserControl that is basically a Button with a control template that contains a TextBlock (I could have done this a number of other ways, I know, but I figured the button already exposes a Click event, so why not?). Things are getting a bit hairy, though, when it comes to styling: I'd like to give the text a "hyperlink" sort of format--blue text, underlined--so that it's clear they are links (also, so that they resemble to format in the legacy WinForms application I'm re-implementing). But I would also like to be able to style the text--ideally, it should grab things like text color if text color is set in a style on the parent cell.
Basically, is there an easy way to implement a custom UserControl that will a) grab styles from a parent element and b) apply its default styles in a low-priority way, i.e. only apply a specific style if there's not already one set from the parent? I know I can pass the parent's style manually through a binding, but I was wondering if there was an easier way.
It sounds like you need to create a true Control or ContentControl implementation for this, so that you can override the true styles and templates.
UserControls are not really stylable, unless you start somehow creating custom properties for binding Styles.. but none of that will be implicit.
I'm trying to create a control in Silverlight that inherits from Button so that I can perform a specific action everytime it is clicked. I'm doing this because I'd like to reuse this custom button in several locations with the same functionality.
I'd like to create the control in such a way so that I have a can set the custom Button's Content to a specific default icon image, but still have the rest of the button's style coming from either the default button style, or being automatically set by the toolkit Themes.
I'd also like to have the Content be described and editable in XAML rather than code if possible.
It seems like this would be a pretty common problem for Silverlight developers - is there a good way to tackle it?
If you use a normal button and edit an "Empty Template", then you can style the button to have any content you wish and expose properties that you can set in the XAML for Icons etc.
By using the standard button control, you will have all the behaviors that you require.
I believe this is what you're looking for, if not can you expand on your question.
--EDIT--
Ok, I get what you are trying to do now. So what you might want to consider is creating a custom button class that inherits from Button. Then you can override the OnClick method to handle your logic. When it comes to the XAML, you can create a template style for a TargetType of your custom button class, that would be styled to your requirements.
HTH, if you need some examples place a comment and I'll mock up some examples