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

Top 5 Contributors of the Month
Post New Web Links

What to do with XAML file and cs?

Posted By:      Posted Date: September 30, 2010    Points: 0   Category :ASP.Net

I downloaded some xaml controls, they are like dials and gauges.  I have referenced the DLLs in my ASP.NET Web application.


I want to add the control to a .ascx web user control - can anyone tell me what I need do to?


Many Thanks 

View Complete Post

More Related Resource Links

How to Read values from the XAML file at Runtime

Hi , I am creating a BuildDefinition from code and Loading the Build Process template. Now,I want to read and Validate the Build Process template parameter values.When I am debuggig,I could see that these are in Xaml format. Ex: I have some value "BuildType" as "Daily" in xaml file.I want to read these values and validate them I dont know what is the bestway to read the values.Can any one please let me know how can we do it. Thanks, Srikrishna              

How to add 3D object from xaml file to my viewport3D?

I have viewport3D and I want to add multiple 3d objects defined in xaml files to this Viewport3D, but by default 3d object deffined in .xaml file comes already with viewport3D and I can not add it to my Viewport3D How I can use those 3D objects from .xaml files in my Viewport3D? I tryed to read xaml with XamlReader cast it to viewport3D and then take vieport3D child elements and add to my viewport, but I get error "Specified Visual is already a child of another Visual or the root of a CompositionTarget." 

Themes/Generic.xaml issue when file is Link from another project


I have two Project A and B that use a Themes project. In the Themes project, I defined a Generic.xaml file. If I run the program on the A project, it works.

But in the second project (B) I don't create the Generic.xaml file but link (add existing item -> add as link) it from the first project (A). When I run this one I got this error :

'/Theme;component/Themes/Generic.xaml' value cannot be assigned to property 'Source' of object 'System.Windows.ResourceDictionary'. Cannot locate resource 'themes/generic.xaml'.  Error at object 'System.Windows.ResourceDictionary' in markup file 'AssemblyProjectB;component/app.xaml' Line 9 Position 37.

If in the second project (B) I create the file instead of linking the generic.xaml created in the first project (A), it works.

Any idea ?


Load Silverlight XAML file into WPF application



I want to load the XAML file of a Silverlight application to set data bindings into WPF window. I am able to load when x:name=classname is removed. But I want to load when it is present. Please help me if there way to achieve this.


retrieving data records from xml data file using xaml(WPF).


I have an XML data file, and I have designed a XAML file with data binding to the data fields found in the XML data file.

When I run the XAML application, the first XML data record is displayed in the correct fields on the panel.

Is it possible to design an application to retrieve multiple records (multiple instances of each data field) using XAML alone?  or are C# (or VB) "code-behind" event handlers necessary to retrieve(or add) beyond the first record?

How to dynamically add the Visual elments from external file( say CustomButton.xaml) into the custom


We have a requirement on custom control. The visual elements of the control template needs to be ldoded from the external xaml file(from the end user say CustomButton.xaml) based on the user request in order to support the Component UI customization. We ahve followed the layered grid approach as explained below.

We have the custom control which has control tempalte contains 2 grids. In which the first grid(default grid) has the default visual elements. the second grid is empty(The visual elements are loaded dynamically). The triggers and converters are added into control template based on the children of default grid visual element names.

Based on the user request the UI of the control template needs to be updated into the second grid from the external xaml file(c:\test.xaml) which has the necessary visual elements. These visual elements can have the same name which is already used in the default grid children.  For this we define a dependency property called IsCustomXAML. if this property set to true then we will do the necessary logic in the property change call back of IsCustomXAML. they are like below


1. load the visual elements from external xaml file(c:\test.xaml) into the second grid.     

 UIElement externalXAMLElement = (UIElement)XamlReader.Load(new XmlTextReader(control.XamlPath));

Referencing image file stored in project resources through XAML



I'm sure this is super simple but I can't seem to figure this out.  Here is my scenario:

I have a bunch of .jpg image files that are included in a resources folder inside my project.  I want to reference them in XAML as follows:

<Image Name="SobeysImage" Stretch="Fill" ToolTip="Sobeys Image" FlowDirection="LeftToRight" Grid.Column="1" Source="Resources/sobeys1.jpg">

I get the following error message when I try to run the application:

Error 2 The file Resources\Sobeys1.jpg is not part of the project or its 'Build Action' property is not set to 'Resource'. C:\_Development\PhotoTool\PhotoTool\Window1.xaml 10 117 PhotoTool


I made sure that I set the build action of the image to Resource.


What am I missing???

How to retrieve the original XAML file name from code



I would like to display the original filename for the element the mouse is hovering over. Can I retrieve the original XAML-FileName from a FrameworkElement in code?

Paul Sinnema

Take a look at my blog: http://paul.sinnema.ch

XAML StaticReference to another file


How do I make a XAML BasedOn={StaticResource ...} reference to a Style in another file that is not in "this" object's hierarchy? I don't want to put all the shared resources in the App.xaml file.


File1 has something like the following:


<Page x:Class=”MyApp.MyPage”>



        <Style TargetType="TextBox" x:Key="MyStyleText">


Problem streaming xaml file


So I am trying to stream the file "test.xaml" (on the root of my project) to a canvas. I have tried numerous methods and for some reason when I call it to stream the xaml document but it doesn't.

My Code:

System.IO.Stream s = this.GetType().Assembly.GetManifestResourceStream("test.xaml");
StreamReader sr1 = new StreamReader(s); 
string xamlString = sr1.ReadToEnd(); 

canvas1 = XamlReader.Load(new System.IO.StreamReader(s).ReadToEnd().ToString()) as Canvas;


To debug, I made a textblock element called debug1 and I wanted to send my code stream as a string to the textblock (to see where my problem is).

Whats interesting is that after line 2 no code will be executed; I know this because the debug1 textblock isnt populated with any data (it remains with its default "textblock" text value). I do not get any errors back or anything.

I know how to put prewritten xaml on a canvas in a ton of ways. I just want to know why xaml file is not streaming at all (is the code right?) (is there something im forgetting?) (is there a better way of going about this?)

Quicknote: My xaml file is just a page xaml document, there's nothing special about it format wise. Also I have been searching a day now and I haven't found anyone with the same issue.

How to include page.xaml file in existing .net 2.0 project


We have a existing web based project in Asp.net and would like to use third party silver light control in the same application.

We need a help how to include silverlight control and use .xaml to access.

Please help




Is it possible to bind a xaml control's image source directly from the resource file ?


Hi all


Is it possible to bind a xaml control's image source directly from the resource file ?




File Splitter in .Net

I love to do utility programs in .Net. And this is one of them. As I was playing with JSplit (a free file splitter program), I wondered if I could do it in .Net. The framework supports file operations like reading files in bytes and creating them. It is indeed easy to do file operations in .Net Basics on File operations

Upload Multiple File using JQuery in asp.net

In this article I have explained how to upload multiple files using file upload control. I have used jQuery plugin for uploading multiple files.

I have also explained how to check for file type, file maximum size limit using jQuery & also using server side validation code.

Creating Excel file from C#

I used below coding for create a excel sheet.I got from on web site.
In below coding there is no problem.Its create the excel file.If i run second time,its ask to overwrite the current excel file.If I said "Yes" then it ok ,but If I select cancel button,its generate the Error message.The exception is

Upload a File to a SharePoint Document Library - Part I

The following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.

SmtpClient and Locked File Attachments

Got a note a couple of days ago from a client using one of my generic routines that wraps SmtpClient. Apparently whenever a file has been attached to a message and emailed with SmtpClient the file remains locked after the message has been sent. Oddly this particular issue hasn't cropped up before for me although these routines are in use in a number of applications I've built.
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