.net

Setting style on first and last visible TabItem of TabControl

I want to set a style on the first and last TabItems in a TabControl, and have them updated as the visibility of the TabItems is changed. I can't see a way to do so with triggers. What we're after looks like this: | > > > | And the visibility of TabItems are determined by binding. I do have it working in code. On TabItem visibility...

How to tell when Windows is inactive

Various programs can do stuff only when you haven't used the computer for a while (eg screensaver, Google Desktop indexing, etc). How do they know when it has been inactive? Is there some function in Windows that tells you how long it has been inactive, or do you have to use some kind of keyboard/mouse hook to track activity yourself? ...

Good resource for learning Silverlight 2 Development?

Now that Silverlight 2 has been released, I'm looking for good resources to learn Silverlight. I messed around with v1, but I chose at that point to wait until 2 was out before getting heavily involved. I would prefer a book, but it seems that it will be a few months before major publishers release (Wrox, for example). Any good resour...

How do I discriminate between data binding and user actions on WinForm controls

I have what must be a typical catch-22 problem. I have a .NET WinForm control that contains a textbox and a checkbox. Both controls are data bound to properties on a data class instance. The textbox is for price, the check box to indicate that the price is a price override. Also on the data class is a property that holds the item's o...

What is the simplest way to get indented XML with line breaks from XmlDocument?

When I build XML up from scratch with XmlDocument, the OuterXml property already has everything nicely indented with line breaks. However, if I call LoadXml on some very "compressed" XML (no line breaks or indention) then the output of OuterXml stays that way. So ... What is the simplest way to get beautified XML output from an instan...

.NET WinForms: Graphics.MeasureString returns different values than Win32 GetTextExtent

i've been trying to find a method in C# to measure the size of a string. The standard method to measure a string in Win32 is to use GetTextExtent. The real goal is to find the average width and height of a font character. The standard method to find the average width of a character starts from getting the width of all alphabetic characte...

Stability of .NET serialization across different framework versions

A project I'm working on requires serializing a data structure before shutting down and restores its state from this serialized data when it start up again. Last year, we were building for .NET 1.1, and ran into a tricky issue where our code ran on .NET 2.0 a customer upgraded with some software that somehow set 1.1 as default our cod...

Structure Vs Class in C#

When you create an instance of a class with the new operator, memory gets allocated on the heap. When you create an instance of a struct with the new operator where does the memory get allocated, on the heap or on the stack ? ...

Debug .NET Setup Project

How can I debug a .NET setup project? ...

TcpClient field of abstract base class constantly being disposed

Hi, I have an abstract base class with a TcpClient field: public abstract class ControllerBase { internal protected TcpClient tcpClient; It has a method to setup a connection: private void setupConnection(IPAddress EthernetAddress, ushort TcpPort) { if (this.tcpClient == null || !this.tcpClient.Connected) { ...

Url as parameter gets intercepted

In my asp.net mvc app I want to check if a certain url returns a valid response. Therefor I send the url to a method that tests the HttpWebRequest.GetResponse() On my dev server (vs2008) it works just fine. When deployed on production server however, it returns a Bad Request. The method is never hit and my asp.net custom error pages are...

Table with several TBODY tags in ASP.NET

I would like to create (in code) tree of controls that would render as a table with several TBODY tags, i.e.: <TBODY> <TR> <TD></TD> </TR> <TR> <TD></TD> </TR> </TBODY> I tried both Table and HtmlTable controls but had no succes...

Why use boolean instead of char?

Hi, This is a silly question but why does a Boolean take up 4 bytes and a char take up 2 in the .NET framework? It makes me wonder if I should start using chars like a boolean to save memory in large apps. ...

From classic ASP to .net c# or vb?

I'm a hobbyist programmer with couple of database driven mobile web sites and I finally have decided to switch from classic asp to .net. But after couple of days reading I couldn’t decide which way I should go. Shall I learn c# or continue to vb in .net? ...

A working Drag&Drop enabled ListView implementation for WPF?

Hi, Been trying to find a working implementation of a WPF listview (or listbox) where you can order items by dragging them up or down. I have found a few, but none really works, for example this one http://www.codeproject.com/KB/WPF/ListViewDragDropManager.aspx?msg=2765618#xx2765618xx stops working once you have list where you need to ...

Does anyone know where I can find a memory editing user control for .net?

Hello world. I am developing a small application which lists the contents from files of a given format. The file format acts as a template for describing binary data (think binary xml). This allows the clients that produces these files to store data in any way they want, so the interpretion of all types contained are not known. What I w...

Initialising a struct variable to Nullable<int>

Hi, Is there a way to declare a variable as Nullable in c#? struct MyStruct { int _yer, _ner; public MyStruct() { _yer = Nullable<int>; //This does not work. _ner = 0; } } ...

.net reflection and the "params" keyword

In .net, is there a way using reflection to determine if a parameter on a method is marked with the "params" keyword? ...

How do I automatically re-establish a duplex channel if it gets faulted?

Hi, I'm developing a client/server application in .Net 3.5 using WCF. Basically, a long running client service (on several machines) establish a duplex connection to the server over a netTcpBinding. The server then uses the callback contract of the client to perform certain on-demand oparations, to which the client responds in an asynch...

Java Lucene integration with .Net

I've got nutch and lucene setup to crawl and index some sites and I'd like to use a .net website instead of the JSP site that comes with nutch. Can anyone recommend some solutions? I've seen solutions where there was an app running on the index server which the .Net site used remoting to connect to. Speed is a consideration obviously ...