style

A and B, B raises exception only if A is False - conisdered a good style?

Canonical example: while foo.hasBar() && foo.getBar() != spam { do lots of stuff } foo.getBar() will raise an exception if it has no bar. However, it is guaranteed that this expression will not be evaluated unless foo has a bar. Is that considered a good programming style? ...

Horizontal Lines in Comments

I realize that this is largely up to personal preference, but I'm curious whether there are some clear drawbacks to the following; I find myself constantly dividing source code into logical groups (via "comments") within the same file. For example: //---------------------------------------------------------------------------- #includ...

WPF DataGridCheckBoxColumn custom style?

Is there any way to style the checkbox in there? iv tried to define a style for the checkbox but that didn't work. after using mole it seems like the checkbox control does not have a ToggleButton in it it uses a BulleDecorator instead, im not sure of this first time im using mole.. What i want to achieve is that instead of a check box ...

Glossy buttons in wxPython?

This is how they look in vista. They are glossier than the normal buttons and when the mouse is not over them they are flat. They have a correspondent version on Windows XP. Is there a way to get them using wxPython? ...

Is there a preferred style for "checked" or "disabled" in HTML input elements?

The HTML spec shows the disabled and checked attributes for input elements like this: <INPUT disabled name="fred"> Whereas w3schools suggests doing it like this: <input disabled="disabled" name="fred" /> Is there some reason to prefer one style over the other or is it just personal preference? I can't decide which I find more "rea...

Blog integration

I have two questions: From personal experience, what free blog engine is the best to integrate a blog to an already designed website? Since many blogs are using their own template tags, I wanted to know if there was an easier way to integrate a blog than having to learn those template tags? If there is not an alternate way of doing so ...

Is it possible to highlight a ComboBoxItem, but not set it as the selected item?

I have a combobox that I am populating with a list of parts for a Return Authorization receiving app. In our RA system, a customer can specify a return for a Kit, but only actually return part of the kit. So because of this, my combobox shows a list of parts that belong to the kit, and asks the receiver to choose which part was actually ...

Silverlight Listbox Item Style

How would one go about styling a listbox such that the selection has a different text color than the default view? I've looked at this in several ways and because the ContentPresenter lacks a Foreground property. The default control template of the listbox provides several rectangles which one can use to adjust the highlight color. For...

File open: Is this bad Python style?

To read contents of a file: data = open(filename, "r").read() The open file immediately stops being referenced anywhere, so the file object will eventually close... and it shouldn't affect other programs using it, since the file is only open for reading, not writing. EDIT: This has actually bitten me in a project I wrote - it prompte...

Set default style for a type in code-behind

How to set the default style for a type in code-behind e.g. for <ScaleTransform x:Key="scaler" ScaleX="1.25" ScaleY="1.25" /> <Style TargetType="{x:Type ToolTip}"> <Setter Property="LayoutTransform" Value="{DynamicResource scaler}"/> </Style> I need to set the style for the tooltip in code-behind instead of in xaml. ...

Centering an image within an anchor element

I have an anchor element that looks like this <a href="url"><img scr="imgurl"/>Text</a> I'd like the image and the text of the anchor element to vertically align. I've tried adding vertical-align (css), padding, margins, ets, but the image will not vertically align with the text. Should be simple, I just can't figure it out. Any id...

Setting Column Background in WPF ListView/Gridview

I'm looking to set the background of a column in a WPF GridView. Many Google results have pointed towards setting the GridViewColumn.CellTemplate to change the appearance of a column. However, I'm met with an issue when setting the background color; it's not stretching to fill the cell: Here's the xaml I'm working with: <Window x:Cla...

Looking for Custom <code> & <pre> CSS styles in Wordpress!

I'm looking for a way to customize my < code > and < pre > tags in my blog. I'm in need of custom CSS styles/codes. Anyone able to guide me to a few good examples? ...

<style> tag inside any elements will still work?

I see something like this: <div> <style type="text/css"> ... </style> </div> It's very strange,but still work. Is this against the standard? ...

Accessing an element defined in a style's template in wpf?

I have a wpf tab control which I added a scrollviewer to. This is all wrapped into a style which is situated in a resource dictionary. Now, on the window's xaml side, all I do is set . I would like to access the control viewer element, as defined in the style as follows: <Style x:Key="MyTabStyle" TargetType="{x:Type TabControl}"> ...

Accessing an element defined in a style's template in wpf?

I have a wpf tab control which I added a scrollviewer to. This is all wrapped into a style which is situated in a resource dictionary. Now, on the window's xaml side, all I do is set . I would like to access the control viewer element, as defined in the style as follows: <Style x:Key="MyTabStyle" TargetType="{x:Type TabControl}">...

CSS Attribute conflict, which is supposed to win?

If I define a CSS attribute in both a CSS class and inside an element directly, which value ends up being used? Let's use width as our example <html> <head> <style type="text/css"> .a { width: 100px; } </style> </head> <body> <div class="a" style="width: 200px;"> </div> </body> </html> What should the width of the div be i...

How to set ContextMenu of a bound item?

I am trying to achieve the following: <Style TargetType="ListBoxItem"> <Setter Property="ContextMenu"> <Setter.Value> <ContextMenu> <MenuItem Name="mnuEdit" Header="_Edit" Click="MenuItem_Click" /> </ContextMenu> </Setter.Value> </Setter> <Style> But it throws the followi...

Wpf ImageButtons?

Hello! I created a WPF application that has many buttons. Now the customer wants to change all the buttons to icons. For example: All the OK buttons should have the same icon, all the cancel btns and so on. I want to put in all the buttons Style="{StaticResource ButtonStyle_OK}", Style="{StaticResource ButtonStyle_OK}" etc. Now my qu...

Get the Style of a Control {StaticResource {x:Type TextBlock}} in code behind

I want to grab the default Style for a TextBlock in code behind without ever having adding a custom default textblock style to resources in xaml I've got a method like this: public TextBlock DrawTextBlockAtPoint(string text, Style textblockStyle) { //... } that I want to provide an override that just uses the regular TextBlock style...