How do SuspendLayout and ResumeLayout work ?
SuspendLayout and ResumeLayout only prevent ’OnLayout’ from being called. Additionally they only prevent OnLayout from being called for that particular control. So if you have a Form with a Panel in it and call SuspendLayout on the Form, the Panel’s layout will not be suspended. [C#] private void button1_Click(object sender, EventArgs e) { this.Layout += new LayoutEventHandler(Form1_Layout); panel1.Layout += new LayoutEventHandler(Panel1_Layout); // Test one - calling PerformLayout here does not call Form1_Layout. this.SuspendLayout(); this.PerformLayout(); this.ResumeLayout(false); // Test two - calling PerformLayout here calls Panel1_Layout. // Child controls are not suspended when the parent is suspended. this.SuspendLayout(); panel1.PerformLayout(); this.ResumeLayout(false); // Test three, properly suspending layout. this.SuspendLayout(); panel1.SuspendLayout(); panel1.PerformLayout(); // <--- Layout event on Panel NOT called panel1.ResumeLayout(false); this.ResumeLayout(false); panel1.Layout -= new LayoutEventHandler(Panel1_Layout); this.Layout -= new LayoutEventHandler(Form1_Layout); }
How can I obtain a writable copy of a Read-Only Freezable?
This example shows how to use the Clone method to create a writable copy of a read-only Freezable. After a Freezable object is marked as read-only (‘frozen’), you cannot modify it. However, you can use the ’Clone’ method to create a modifiable clone of the frozen object. The following example creates a modifiable clone of a frozen ’SolidColorBrush’ object. [C#] Button myButton = new Button(); SolidColorBrush myBrush = new SolidColorBrush(Colors.Yellow); [C#] // Freezing a Freezable before it provides // performance improvements if you don’t // intend on modifying it. if (myBrush.CanFreeze) { // Makes the brush unmodifiable. myBrush.Freeze(); } myButton.Background = myBrush; // If you need to modify a frozen brush, // the Clone method can be used to // create a modifiable copy. SolidColorBrush myBrushClone = myBrush.Clone(); // Changing myBrushClone does not change // the color of myButton, because its // background is still set by myBrush. myBrushClone.Color = Colors.Red; // Replacing myBrush with myBrushClone // makes the button change to red. myButton.Background = myBrushClone;
How can I use an application resource ?
The following example shows an application definition file. The application definition file defines a resource section (a value for the Resources property). Resources defined at the application level can be accessed by all other pages that are part of the application. In this case, the resource is a declared style. Because a complete style that includes a control template can be lengthy, this example omits the control template that is defined within the “ContentTemplate” property setter of the style. [XAML] <Application.Resources> <Style TargetType='Button' x:Key='GelButton' > <Setter Property='Margin' Value='1,2,1,2'/> <Setter Property='HorizontalAlignment' Value='Left'/> <Setter Property='Template'> <Setter.Value> ... </Setter.Value> </Setter> </Style> </Application.Resources> The following example shows an XAML page that references the application level resource that the previous example defined. The resource is referenced by using a StaticResource Markup Extension that specifies the unique resource key for the requested resource. No resource with the key of ‘GelButton’ is found in the current page, so the resource lookup scope for the requested resource continues beyond the current page and into the defined application level resources. [XAML] <StackPanel Name='root' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> <Button Height='50' Width='250' Style='{StaticResource GelButton}' Content='Button 1' /> <Button Height='50' Width='250' Style='{StaticResource GelButton}' Content='Button 2' /> </StackPanel>
How to make a form transparent
The opacity property enables you to specify a level of transparency for the form and its child controls. The TransparencyKey property will let you make the form transparent while keeping it’s child controls visible (provided they have a different BackColor). See the .NET documentation for Form.Opacity for differences between Opacity and TransparencyKey properties. Opacity only works with Windows 2000 and later.
Why do I get error message ‘Unable to start debugging on the web server. The server does not support debugging of ASP.NET or ATL Server applications. …’?
You would get this error if the application mappings for ASP.NET file name extensions (such as .aspx) are not configured correctly in Microsoft Internet Information Services (IIS). To resolve this go to C:\Windows Directory\Microsoft.Net\Framework\Version and type aspnet_regiis -i to configure the required application mappings correctly On Trying to Debug an application, by the F5 key I get the error: ‘Error while trying to run project: Unable to start debugging on the web server. Catastrophic failure’? This issue occurs if the account that is used to run the ASP.NET Worker process (by default, the ASPNET user account) is not assigned the ‘Impersonate a client after authentication’ user right in the ‘Local Security Policy’ settings. This issue may occur when you install Microsoft Visual Studio .NET after you install Windows 2000 Service Pack 4 (SP4) on the computer. In this situation, the ASPNET account is not assigned the ‘Impersonate a client after authentication’ user right in the ‘Local Security Policy’ settings.To resolve it, please use the method at: To work around the problem, manually assign Impersonate a client after authentication to the IWAM account. To do so, follow these steps: Click Start, point to Programs, point to Administrative Tools, and then click Domain Controller Security Policy. Click Security Settings. Click Local Policies, and then click User Rights Assignment. In the right pane, double-click Impersonate a client after authentication. In the Security Policy Setting window, click Define these policy settings. Click Add, and then click Browse. In the Select Users or Groups window, select the IWAM account name, click Add, and then click OK. Click OK, and then click OK again. To enforce an update of computer policy, type the following command: secedit /refreshpolicy machine_policy /enforce At a command prompt, type iisreset. In case your server is a Domain Controller Refer PRB: ‘Catastrophic Failure’ Error Message When You Try to Debug an ASP.NET Application on Windows 2000 Domain Controller