attachedproperties

SortDescription with custom attached property

Hi, In Xaml I can set a custom attached property using local:TestClass.TestProperty="1" An I can bind to a custom attached property using {Binding Path=(Namespace:[OwnerType].[PropertyName])} {Binding Path=(local:TestClass.TestProperty)} But how do I specify the namespace when I need to use a custom attached property in a SortDescript...

WPF TextBox lostfocus as attached property

I have a Grid with many TextBoxes and I want to call NotifyPropertyChanged() method to update some other controls everytime one of these TextBox-es changed the value = lost the focus (I don't want to use PropertyChanged as UpdateSourceTrigger) This is what I can do: <Grid TextBoxBase.TextChanged="My_TextChanged" > ... </Grid> I ne...

What are the various uses of Attached Properties?

I've seen some really varying uses of AttachedProperties so far in my adventures in WPF, and am wondering, what are some of the various uses? I've seen fairly mundane uses, such as those found in Grid and Canvas, as well as some really cool hacks allowing binding to collections without setters. What other applications have you found fo...

Using attached properties to

hello all, Is there a way to bind an image into a button so that the users sees an image and then the text. In the past I have done this using templates within the xaml however this time I have built the button using styles defined within a resource dictionary. I did this mainly because I wanted to content presenter text to change color ...

Attached property problem

Hi, I have a attached property which name is "Translate". I set the property like this: <Label Target="{Binding ElementName=UserName}" Content="User Name" Extensions.Translate="true"/> I get the Target value in the property changed event handler and it is null. But I set it in the XAML. Why is it null? Thanks. ...

WPF: Attached behavior is registered but never called?

Hello all, trying my first attached behavior: I want to bind the TextSelection of the RichTextBox to my ViewModel`s property: public TextSelection SelectedRichText {get;set;} That way I bind it: <RichTextBox behavior:RichTextBoxSelectionBehavior.RichTextBoxSelection="{Binding SelectedRichText}" /> Thats my code and I have 2 quest...

DependencyProperty dependencies and PropertyCallbacks

The heart of the question in this post is whether you can expect all DPs to be set by the time a Property callback for one of them is set. I ask this because this is not the behavior I am seeing. A class has two DP's, both of which are set in XAML, like so: <!-- Days of the Week --> <local:DayOfTheWeekColumn DowIndex="0" Acti...

Complex Attached Property Behaviour

I've got an object (Decorator) that defines an attached property for any of it's children. So far I have no issue setting/getting the attached property on the remote object: public static readonly DependencyProperty RequiresRoleProperty = DependencyProperty.RegisterAttached("RequiresRole", typeof (string), typeof (U...

WPF Custom Attached Property in DataTrigger

I've looked at similar questions here on SO and wasn't able to get a solution, so here's my deal: ** I Have the following class: ** public static class ControlSecurity { public static readonly DependencyProperty IsSecuredProperty = DependencyProperty.RegisterAttached( "IsSecured", typeof (bool), ...

Is storing info in unrelated attached properties a code smell?

I was just watching a "how-to" type WPF video called How Do I: Use Attached Properties to Store Extra Data in WPF, and it was describing what to do when you want to associate two pieces of information with a single control. If you want to put one piece of information in, they say to use the Tag property. <Grid> <TextBox Tag="innerD...

DependencyProperty of Type Delegate

Hello, I have created an attached behavior that is used to execute a Delegate of type Func<bool> when the behavior is invoked. Below is the dependancy property definition. public static readonly DependencyProperty SendToDetailBehaviorProperty = DependencyProperty.RegisterAttached("SendToDetailBehavior", typeof(Func<bool>), typeof(ListD...

Wpf styles and attached properties

Hi, I've been playing with behaviors and I came across a interesting issue. Here is my behavior: public class AddNewBehavior : BaseBehavior<RadGridView, AddNewBehavior> { public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached("IsEnabled", typeof(bool), typeof(AddNewBehavior), new Framework...

When to use AttachedProperties in wpf

Here are my doubts, When to use AttachedProperties in wpf Should I use AttachedProperties only with ContentControls (like Panels) where are there one or more children What is the use of AttachedProperties Can I use AttachedProperties for extending properties of a control, i.e., properties that don't exists but I would like t...

Why is XamlReader.Load unable to recognize my attached property in Silverlight 4?

I'm trying to figure out how to programmatically apply a theme at runtime in our Silverlight 4 application. I figured this should be as simple as loading a resource dictionary from XAML and merging it with the application's merged dictionaries. Here's my code so far: var themeUri = new Uri( "OurApp;component/Themes/Classic/Theme.x...

Removing the render transform of a child element

Ok, So I have a situation, where an border is being scaled (sometimes by a large amount) and translated. Inside the border is a grid, and inside the grid are two images, one is a photo and is stretched to the size of the border, and the other, I intend on being an icon, which needs to be a fixed size in the bottom left hand corner. Th...

Calculate sum , average based on list of items in WPF

Hi, In WPF, I want to display sum, average values based on the List of Items provided. For example, I have an Employee object with Salary Property, and I want to calculate total salary based on the employee list. Also, the employee object is data bound to a Items control where the Salary will be edited/new Employee may be added to the ...

Is It possible to use IMultiValueConverter for a List of Items?

I have EmployeeList as a observableCollection of Employee Object. The Employee object has Salary. I want to display few values like average Salary of the Employees in XAML, and the UI field should be automatically updated when an item is added to the List or When Salary field is changed in any of the items updated. This can be achieve...

WPF set attached event programatically

Can someone explain how you do this programatically in WPF? <window Validation.Error="ItemError"></Window> I am trying to set the attached event for Validation.Error through code, but cannot quite figure out how to do it. ...

Attached Properties in XAML without the word 'Property'

MS defines attached properties like 'Grid.RowProperty' and 'Grid.ColumnProperty', but in XAML you just call it with 'Grid.Row' and 'Grid.Column' I tried doing the same with an attached property called 'MyValProperty' that was registered with the name 'MyVal' on the class 'Foo', but the XAML won't let me type 'Foo.MyVal' and instead make...

Attached property declaration in xaml

I'm creating attached property. My attached class is helper:FocusDetail and has 2 property. second property DetailBody type is object. I'm using this property on items control <ItemsControl ItemsSource="{Binding Riches}" BorderThickness="0"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBox Text="{Binding TextInfo}" ...