.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Using an Application Resource in Nested UserControl

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :WPF
Hello This problem has been niggling me for months and I just can't seem to get to the bottom of it. I have a UserControl, let's call it 'UC_List', and the ListBox in it uses a Style which I have declared in my Application.xaml file. When working with UC_List.xaml everything seems fine. I then place 'UC_List' into a UserControl, let's call it 'UC_Summary'. I have declared the namespace at the top of UC_Summary.xaml. The xaml code in UC_Summary now has an Error: Could not create an instance of type 'UC_Summary'. Now I cannot see anything in the Design window, only a warning saying 'Problem Loading, the document contains errors that must be fixed...' However when I run the application everything works fine! After a lot of trial and error I found that the cause of the problem seems to be the Style referenced in the Application.xaml. If I declare the Style in UserControl.Resources at the top of UC_List the error goes away and the graphics in UC_Summary return. I've so far duplicated my Styles into individual UserControls to work around the problem but this could easily lead to inconsistancies. If anyone can suggest anything I would be really pleased to try it. Thank you. Regards Chris

View Complete Post

More Related Resource Links

When binding Style on a UserControl to Application.Resource a consumer of the usercontrol fails to r


I have a WPF application that has a UserControl called 'Address' which sets up a simple form with a grid some labels and some data input controls (TextBoxes..etc.)

I made a little style resource to add a gradient to a grid row background for my headings like this:
        <Style x:Key="GridHeaderFade" TargetType="{x:Type Grid}">
            <Setter Property="Grid.Background">
                    <LinearGradientBrush ColorInterpolationMode="SRgbLinearInterpolation" >
                        <GradientStop Color="#FFFFFFFF" Offset=".3"/>
                        <GradientStop Color="#B0a0a0a0" Offset=".85"/>
                        <GradientStop Color="#FFFFFFFF" Offset=".99"/>
Then in my address control I use:
<Grid Grid.Row="0" Style="{StaticResource GridHeaderFade}" >
            <Label HorizontalAlignment="Left" Margin="0,-7,0,0"  FontSize="

SharePoint 2010: Application Lifecycle Management (ALM) Resource Center

Are you looking for information about BCS? BCS enables users to read and write data from external systems-through web services, databases, and .NET assemblies.

Nested controls in UserControl return null (FindControl)

Hi everyone, I have a very weird issue. I have a UserControl that has some controls inside. I want to refer those controls after, in another postback. But when I try to get them the ".Controls" property of my controls returns null. I'm working on vs2008 Here is the sample code: public partial class MyUserControl : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { foreach (Control control in this.Controls) { Response.Write(control.ClientID); } } private void MyTable() { Table table = new Table(); TableRow row = new TableRow(); TableCell cell = new TableCell(); CheckBox check = new CheckBox(); check.ID = "theId"; check.Text = "My Check"; check.AutoPostBack = true; cell.Controls.Add(check); row.Cells.Add(cell); check = new CheckBox(); check.ID = "theOther"; check.AutoPostBack = true; check.Text = "My Other Check"; cell = new TableCell(); cell.Controls.Add(check); row.Cells.Add(cell); table.Rows.Add(row); this.Controls.Add(table); } protected override void Render(HtmlTextWriter writer) { MyTable(); base.Render(writer); } } And in the Default.aspx is like:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.cs" Inherits="Tester.Default" %> &

Nested UserControl Render Order

I have a custom control created in codebehind, and I have in the same control an ordinary asp.net button. Like this: protected void Page_Load(object sender, EventArgs e) { } private void MyTable() { Table table = new Table(); TableRow row = new TableRow(); TableCell cell = new TableCell(); CheckBox check = new CheckBox(); check.ID = "theId"; check.Text = "My Check"; check.AutoPostBack = true; cell.Controls.Add(check); row.Cells.Add(cell); table.Rows.Add(row); this.Controls.Add(table); } protected override void CreateChildControls() { MyTable(); base.CreateChildControls(); } And in the asmx something like this:<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyUserControl.ascx.cs" Inherits="Tester.MyUserControl" %> <asp:Button ID="Button1" runat="server" Text="Button" /> ok... now. When I render my control it looks like: [BUTTON] [ ] My Check But I really need that the button render after the checkbox. Any idea how can I do that?

Nested control's events not firing in UserControl


Hello I have a weird issue. I have a user control which I load dynamically using LoadControl. In this UserControl I have a button with assigned OnClick event, but when I click that button, the event is not fired. I'm populating the user control in UpdatePanel's Load event (I invoke __dopostback from JS).

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ServiceInput.ascx.cs"
Inherits="uPay.UserControls.ServiceInputs.ServiceInput" ViewStateMode="Disabled" %>
    <div class="PopupFoot">
        <asp:Button ID="btnAdd" CssClass="PopupADD" runat="server" OnClick="btnAdd_Click" />

    protected void btnAdd_Click(object sender, EventArgs e)
        //Method never gets called :/

 Here I load user control in the page

protected void ServicesUpdatePanel_Load(object sender, EventArgs e)
        string arg = Request.Params.Get("__EVENTARGUMENT");
        if (arg == "ServiceInput")
            int serviceId;
            if (Int32.TryParse(hdnSelectedService.Value, out serviceId))
                using (Entities db = new Entities())

WPF Application Z-Order Bug when closing "nested" dialogs


I have encountered a very easily reproduced and exceedingly frustrating bug in WPF when using "nested" dialogs (i.e. windows "owned" by the window that opens them).  Here  is a quick description of a situation that causes the problem:  

MainAppWindow opens WindowA modelessly.  WindowA is owned by MainAppWindow.

WindowA opens WindowB modelessly (or modally, doesn't see to matter).  WindowB is owned by WindowA.

Close WindowB - everything is as expected: WindowA is on top of MainAppWindow and app is in foreground of desktop.

Close WindowA - WindowA closes but MainAppWindow is dropped to background of desktop (i.e. behind any other open applications).

The following simple application demonstrates the problem.  Just click construct 2 nested dialogs them close them in reverse order.  You will need to have another application like notepad in the background so that you can see the WPF app main window get dropped behind it.

To Reproduce:

   - create a new WPF application in Visual Studio (I'm using 2008, sp1) and copy/paste the following code for the Window1.xaml and Window1.xaml.cs files.  I have been able to reproduce this issue on XP, Win7 and Vista.


<Window x:Class="OwnedWindowZOrderIssue.Window1"


Application Resource and Event Handlers


I found a topic quite similar to my problem but ton the same I think. So I decided to post anyway

The thing is I have a CellTemplate Application Resource that I want to use in DataGrid TemplateColumns used for refresh.

The problem is that in the DataTemplate I have an image and I want to be able to set the MouseLeftButtonUp in the WPF Window or Control that I use the CellTemplate Resource. I made various attempts to some-how "overload" the resource in the Window but with no result. Can someone please enlighten me?

There follows the code snipet from the <Application.Resources> section

<DataTemplate x:Key="refreshColumnTemplate">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
 <Image HorizontalAlignment="Stretch" Name="image3" Stretch="UniformToFill" VerticalAlignment="Stretch" Source="..."
  Width="22" Height="22" Cursor="Hand" MouseLeftButtonUp="Should I put something here?"/>

in the WPF Window the usage of the data template looks like this:

<DataGridTemplateColumn ... CellEditingTemplate="{StaticResource refreshColumnTemplate}"

The type initializer for 'Nested' threw an exception for BDC USING Application Definition Designer



Is anyone know what this error could mean?

The type initializer for 'Nested' threw an exception.

when i am executing instance method using "Application Definition Designer" for BDC.

Same ADF file works fine locally but getting above error message when executing on server.(both sharepoint are different) and install on different machines.

When executing BDC catalog file in sharepoint. We are getting below error message.

An error occurred while retrieving data from CustomerBDC_Instance. Administrators, see the server log for more information.

Event log:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">

- <System>

<Provider Name="Office SharePoint Server" />

<EventID Qualifiers="0">5703</EventID>




<TimeCreated SystemTime="2010-10-22T12:20:39.000Z" />



<Computer>[LOCAL COMPUTER ADDRESS]</Computer>

<Security />


- &l

Cannot access Application Level Resource if it's the only resource in the dictionary


I've declared  two resources in App.xaml as shown:

    <sys:String x:Key="Foo">Foofoofoofoo</sys:String>
    <sys:String x:Key="Bar">BarBarBar</sys:String

Microsoft's Collaborative Application Markup Language (CAML) Loop

discovered an interesting error recently while working with Microsoft's Collaborative Application Markup Language (CAML) that, surprisingly, had received no ink. Partly what surprises me about this is that the error may require you to rewrite large sections of your code if you haven't previously considered this SharePoint limitation. I'll start with some context, but first of all the error is:

Integrating a Legacy Web Application in SharePoint

This month we will continue with the theme of deploying Microsoft's SharePoint as a company intranet by describing a method for integrating a legacy Web application inside a SharePoint site.

In many companies the intranet site is not just a home page with announcements. It houses Web applications used by many different departments. In last month's article, I built a page to search the employee table in Northwind (the sample database included in Microsoft's SQL Server). This month, I will move the Web pages used to add/remove records from the table into the SharePoint intranet.

MVC architecture in ASP.Net using C# and Microsoft Data Access Application block

The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]:

Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).

View. The view manages the display of information.

Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.

High-Performance .NET Application Development & Architecture

It has always been a goal of project architects to plan an effective strategy from the ground up in regards to an new application. All relevant factors are taken into consideration with respect to the application, from its design and layout to a functional website infrastructure. Pre-.NET strategies and design guidelines still effective now were developed with Microsoft's DNA (Distributed interNet Application) platform. This model successfully served the purpose of architecting N(any number of)-Tier (levels) applications. In its basic sense, as in most robust, distributed applications, you'll architect 3 main layers or Tiers: presentation, business rules and data access.

Application architecture in asp .net

Application Architecture is the most important process of developing a good application. Some people tends to jump into coding without any architecture laid. Later we see those people changing the architecture and finally the application had to be developed from the scratch with the correct architecture.

In this article I will describe some details about how you can improve the architecture of you application. This article is targeted to the beginner's audience.

Improving Application Performance in .Net

Application performance has always been a concern for Web Application developers. This article contains guidelines and tips for maximizing application performance in ASP.NET.

Logic behind N -Tier Application Development

In the arena of application development, developers all over the world use various programming languages, technical processes, and technical tools. While using number of technical & non technical elements the processes or methods become complex, for simplification of the application development process, developers use various techniques such as dividing the application architecture into layers or parts. In the professional & technical language this separation or division process is called N-Tier Application Development process, where "N" stands for number and "tire" stands for layers or parts.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend