style

How to make button's width autofit the text of a button?

I am currently doing this, but I am doing something wrong :): <Style TargetType="{x:Type Button}"> <Setter Property="MinWidth" Value="90" /> <Setter Property="Width" Value="Auto" /> </Style> I want the buttons to have some minimum width but also to have their width expand to fit the text of the button. ...

In Java, should variables be declared at the top of a function, or as they're needed?

I'm cleaning up Java code for someone who starts their functions by declaring all variables up top, and initializing them to null/0/whatever, as opposed to declaring them as they're needed later on. What are the specific guidelines for this? Are there optimization reasons for one way or the other, or is one way just good practice? Are t...

WPF: Apply ScrollBar Style to ListBox Template - Error object cannot be added to border

Hi, I thought this may be straightforward question but did not find any definitive answer while searching net or SO. I have created scrollbar style (using standard scroll bard template - Blend 2) I am not sure how to apply this style "MyScrollStyle" to a ListBox Template . I saw on ListBox template they have Scroll Viewer --> whic...

Setting AIR Application backgroundcolor strips child styles

I set the following style properties to my flex/AIR application to achieve a transparent background so I could create a non-square/rectangle shape. Application { /* make app window transparent */ backgroundColor:""; background-image:""; padding: 0px; margin-top: 0; margin-right: 0; ...

WPF Popup: How to put a border around the popup?

I've got a popup in my XAML to show some information. When the box pops up, it has no border and appears to blend into the background of the page. It just needs a border, and ideally a drop-shadow behind it to show some sort of layering and focus. Any ideas how to style a Popup to have a border and possibly the shadow-effect? ...

cant find a reason for this bug

i just found a solution to one of the wierdest bug i have ever seen and i am still trying to find the reason ... i got a old CMs in Classic ASP. in the editor page theres a javascript changing an image property function removeimg(objimg){ objimg.onclick = ""; objimg.src = "/Logiciel/_Altitude_image/interface/Gestion_acces/space...

Silverlight 2 ImplicitStyleManager and Combobox

Hi, When I create a template for a combobox in generic.xaml, I get crashes with a combobox that contains Images. Even if the template is a exact copy of the original one. When I remove the template from generic.xaml, everything works. Is this a known problem or am I doing something wrong? I have tried the template found in System.Wind...

How can I trigger a control event when a ListViewItem is selected?

I have an image that I want to show only when a ListViewItem is selected. The code I have isn't working, but I think it illustrates what I want to accomplish. <GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <Image Height="20"> <Image.Style> <Style TargetType="{x:Type Image}"> ...

Silverlight PRISM and 'loose' style files

Hi, We are looking at starting a new Silverlight project using the PRISM framework (to benefit from modules etc) and I am still a little unclear about the best styling approach. What I'd ideally like is to have editable XAML files (maybe even just 1 for the whole project) containing the application's style so that they can be edited to ...

Migrating from one C language to another, change Style?

I find myself in conflict, regarding which code style i should follow when using a different c language. Currently i am doing work (different projects) in c++, c# and objective-c I noticed there is a lot of discrepancy in the conventions basic frameworks follow. Generally, i dont think it's a bad idea to adhere to these convetions, as ...

WPF Styles, BasedOn, & Storyboards

I am trying to create a simple style that highlights the focused UI Element (Textbox,combo,etc) while it has focus, and goes away when lost focus. I came up with this: ` <Style TargetType="{x:Type FrameworkElement}" x:Key="OnFocus"> <Setter Property="Effect"> <Setter.Value> <DropShadowEffect Col...

Accessing child and parent elements in Silverlight styles on different states

I'm currently styling a Silverlight combobox. The designer wants the combobox to turn black on "pressed", a state that is not supported by the combobox itself, but is available on the togglebutton ("DropDownToggle") within the combobox. So I edit the template for the togglebutton, and make it black on "pressed". No problem. The problem ...

Applying WPF styles to Child Items

Hi There Lets say I have a grid, within my grid I have a number of controls. Instead of setting the margin for each of these controls, I wish to create a style to set the margin for ANY control I drop into a grid. Is this possible? I was hoping that the following would work: <Window.Resources> <Style x:Key="DefaultMargins"> ...

Should I use $hash{"string"} or $hash{string} in Perl?

In Perl, which of these is the "better" style? $hash{"string"} or $hash{string}? In any case, are they functionality identical? ...

Very Tricky CSS Scrolling Question

Hi. I am not sure how to achieve a certain effect in CSS. I have the following HTML: <div id="container" name="container"> <div id="scroll" name="scroll"></div> </div> The scroller loads with one image inside the scroller which has a width: 715px; [ [1] ] When the user clicks on that image, a second image is dynamica...

controlling border length

i want to limit the border length applied to a div element(or any HTML elements) . For example consider a div of width 100px, is there anyway to apply the border to only 40px width itself? ...

Silverlight changing styles based on an objects property value (ie DataTrigger)

Hi, Does anyone have a successful workaround for changing a style in silverlight based on a property of the underlying data object, in that when the value changes so does the style. I used WPF briefly and it obviously has the DataTrigger which seems to cover this but it is missing in Silverlight. I found this: http://blois.us/blog/2009...

controlling list indexing

In html the list (ul and ol ) provides indexing like 1.main 1.1 sub1 1.2 sub2 1.2.1 .... i want indexing as 1. main 1.1 sub1 1.2 sub2 how to do this ...

How to add a trigger to a WPF custom control without overriding the existing style?

I am creating a simple custom control extending from toggle button that allows the user to specify checked and unchecked content directly in XAML. It works well but it is based on a trigger, and I don't know how to define the trigger except in a style. If I define the style, then I lose anything set outside of the custom control. What...

C# DataGridView Color text of single row

I have a DataGridView that has a class as its DataSource. The class contains an ID string, 2x DateTimes and a Boolean. I have written some code to change the text of a row that matches an ID I pass to method to Red, but nothing I have tried works. This is what I have so far: public void ShowInstanceAsTerminated(String id) { forea...