.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 argument in an attached property

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :JQuery


I've written a workflow level ErrorMessage as an attached property on the root workflow activity, at design time.  I made the attached property for ErrorMessage written as an InArgument (to support some custom control that works well with InArguments).  Here's some of the design time code:

            AttachedProperty<InArgument<string>> ErrorMessage = new AttachedProperty<InArgument<string>>
                OwnerType = typeof(ActivityBuilder),
                IsBrowsable = true,
                Name = "ErrorMessage",
                Getter = (mi =>
                    InArgument<string> temp;

View Complete Post

More Related Resource Links

Setting an attached property by a Setter element?

I have the fragment below as contents of a <Grid> element. The idea is that if the checkbox is checked the <TreeView> element should only span one instead of two columns. When I check the checkbox the background of the treeview turns red, but the treeview continues to span 2 instead of 1 column. It's a bit like the attached property Grid.ColumnSpan does not get assigned by the <Setter Property="Grid.ColumnSpan" Value="1"/> at all. What should I do in order to achieve what I want?Best regards,Henrik Dahl   <TreeView    x:Name="Blas"    ItemsSource="{Binding Path=BlasRoot.Children}" d:LayoutOverrides="Width" Margin="0,0,0,8" Grid.Column="0" Grid.ColumnSpan="2">    <TreeView.Style>       <Style>          <Style.Triggers> <DataTrigger Binding="{Binding ElementName=chkPosition, Path=IsChecked}" Value="True">    <Setter Property="Grid.ColumnSpan" Value="1"/>    <Setter Property="TreeView.Background" Value="Red"/> </DataTrigger>          </Style.Triggers>       </Style>    </TreeView.Style> </TreeView> <CheckBox HorizontalAlignment="Left" Margin="-50,0,0,0" x:Name="chkPosition" VerticalAlignment="Top" Content="

How to assign a workflow argument with Direction=Property to a workflow variable?


I created an argument 'ArgTest' with Direction=Property and ArgumentType=String and a variable VarTest with VariableType=String.

I'd like to assign ArgTest to VarTest. Direct assignment (using Assign activity) doesn't work, because there is a compiler error "'ArgTest' is not declared. It may be inaccessible due to its protection level".

I tried to change definition of Assign activity in XAML using PropertyReference (which is System.Activities. ActivityPropertyReference) :

<Assign sap:VirtualizedContainerService.HintSize="242,58">
  <OutArgument x:TypeArguments="x:String">[VarTest]</OutArgument>
   <PropertyReference x:TypeArguments="x:String" PropertyName="ArgTest" />  

, but I got runtime error: "Object of type 'System.String' cannot be converted to type 'System.Activities.Activity`1[System.String]'."


From another reasons it's important for me to have Direction of ArgTest set to Property instead of In.

I believe the solution must be easy, so I feel like I'm missing a trick. Thanks in advance for any pointers.

Attached Property


I am working a project that has several different controls that I am trying to use an attached property to dictate whether or not to perform a recalculation operation if changed.  I am using what I thought was the standard pattern for the creating of an AP.

    public class RecalcProperty : DependencyObject
        public static readonly DependencyProperty PerformRecalcProperty = DependencyProperty.RegisterAttached(
          new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.None)
        public static void SetPerformRecalc(UIElement element, Boolean value)
            element.SetValue(PerformRecalcProperty, value);

        public static Boolean GetPerformRecalc(UIElement element)

WF4 Use Property as Argument


Hello everyone.

My scenario is the following: I have a workflow (lets call it customActivity1) that do the basic actions for my system. I also have another workflow (customActivity2) that uses customActivity1 and do higher level actions. In other words, CA1 is inside CA2. When I call customActivity1, I must pass on a few parameters, like Boolean or String values. This means that I must bind the CA2 public variables to CA1 arguments. I want to show some of these parameters as a checkbox or combobox (so the developer of customActivity2 can pass on only valid values) and found out that I can do that by setting the argument as PROPERTY (instead of In). By doing a research, I also found out that you can’t directly use this argument in expressions, so I keep getting errors on my customActivity1.

That said and knowing that I need to narrow what the designer can pass on, how could I do that without using an activity designer or where could I find an answer?


Thanks in advance

Attached property usage error (Repost for clarity)

<Window x:Class="WpfApplication4.Window1"
  Title="Window1" Height="300" Width="300">
    <TextBox Height="23" Margin="86,0,72,106" Name="textBox1" VerticalAlignment="Bottom" Style="{StaticResource BigHonkingDigitOnlyTextBox}" />

    <Style x:Key="BigHonkingDigitOnlyTextBox" TargetType="TextBox">
      <Setter Property="FontSize" Value="36" />
      <!-- honking

Attached property usage error

I am trying to use attached property...

And i get errors ... here is my code


Window x:Class 





Title="Window1" Height="300" Width="300"> 



<TextBox Height="23" Margin="86,0,72,106" Name="textBox1" VerticalAlignment="Bottom" Style="{StaticResource BigHonkingDigitOnlyTextBox 
}" />






<Style x:Key="BigHonkingDigitOnlyTextBox" TargetType 


<Setter Property="FontSize" Value 
="36" />


<!-- big -->


<Setter Property="local:InputBehaviour.HonkOnKeyPress" Value 
="True" />


<!-- honking -->


<Setter Property="local:InputBehaviour.IsDigitOnly" Value 
="True" />


<!-- digit-only -->































Closing ChildWindow In MVVM by Using Attached Property

In this post I will show you how to close the ChildWindow of Silverlight using Attached property in MVVM. Let us start with the example code. For this example I have created Silverlight project of template "Silverlight Navigation with Accent Color" application. I have added new ChildWindow in the view folder with the name UserInputForm and then UserInputFormViewModel in the ViewModel folder which is the used to set as the DataContext of the UserInputForm.

WPF / Silverlight tutorial: Visibility property and binding

Visibility property is a very powerful and yet often overlooked property available in both WPF and Silverlight. It enables you to set Visibility of certain UIElement objects to different states like: Visible, Collapsed and Hidden (not supported by Silverlight). This tutorial shows you how to use it and how to bind to Visibility property

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

n this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

Jscript error: Object does not support property or method


 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo

Content page control passes as argument to javascript function


Here is the content page:


<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="JavaDynamicCopyValue.aspx.cs" Inherits="JavaDynamicCopyValue" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <script type="text/javascript" >
 function copyValue(input, output )
   ouput.value = input.value;
   return true;
 <asp:TextBox ID="txt1" runat="server" onchange="copyValue(this,document.getElementById('<%=txt2.ClientID%>'))"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>


I got a javascript run time error says output is undefined. if I view source of the page, the txt1 markup became:

<input name="ctl00$ContentPlaceHol

Is it possible to populate property choices from a database?


I'm creating my first server control, and have it working where I can set up an enum and the user can set a property's choices,  based off of that enum.  But I'd like it to pull records from a database and populate the list of choices for the property from a database.  This would allow me to add a new "Host System" to the database, and the other designers wouldn't have to get a new copy of the dll.



Custom Server Control Property not maintaining state


I have created a server control consisting of a TextArea and a div under it.  My goal is to create my own asp:TextArea type control.  the div is for a Character count of the text area and seems to work ok but i added a CharacterCountVisible property to the control that is always returning true.  See Proptery definition below


<Bindable(False), Category("Appearance"), DefaultValue("True"), Localizable(True)> Property CharacterCountVisible() As Boolean
        Return _CountBoxVisible
    End Get
    Set(ByVal value As Boolean)
        _CountBoxVisible = value
    End Set
End Property

Note the _CountBoxVisible variable is define inside the class as :

Dim _CountBoxVisible as Boolean = True

What I am trying to do is give the user/coder the option to show/utilize the char count feature.  Can make it disappear with textarea1.CharacterCountVisible = False but setting it to true will not make it display.


What am i missing





Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

Need to know (the value of a) clientside property on the serverside


I need to know on the serverside, if a RadioButton has been disabled (by javascript) on the clientside.


The (serverside) Enabled property is not the same as the (clientside) disabled property. Using MyRadioButton.Attributes("disabled") doesn't do the trick either.


Any clue?

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