Hey Everyone,
I am trying to get a better understanding of DependencyProperties in WPF. One thing I am trying to get clarity with is the LocalValue. There is a function called ReadLocalValue that is supposedly supposed to return the local value of the property otherwise it should return UnsetValue.
For instance I have a TextBlock named "justATest" with the TextProperty value set to "Test" on the element.
When I try calling:
MsgBox(ReadLocalValue(CType(justATest.TextProperty, DependencyProperty)).ToString)
All that gets returned is {DependencyProperty.UnsetValue}
Shouldn't I be getting back the value "Test"?
Can anyone shed some more light on the Local value and how the ReadLocalValue function works. Also are their any good resources out there that explain this?
Thanks,
Nick U
Shouldn't you be calling
justATest.ReadLocalValue(TextBox.TextProperty)
Related
My question lies in the following code. Though the code is not working now. I wan't to rewrite it in proper way so that it works.
<span ng-if="community = vm.getCommunity(invite.community_id)!=null" grv-icon-comm-type="vm.communityViewHelper.getTypeIcon(community)" ng-class="vm.communityViewHelper.getColorClass(community)"></span>
In the above code vm.getCommunity(invite.community_id) returns either null or community object. If community object is returned then I wish to call two more function in the same element where I wish to use the recently receivedcommunity value on those two function.
It's just killing my time. Please help.
Alternatively, you could use a watcher on "invite.community_id" to set community inside a controller function. Could look a bit cleaner depending on the rest of the code.
This function could even set all three values if you like.
I have a wpf datagrid that I want to sort programatically as if the user had clicked on the header. After some searching I found reference to using this:
datagrid_selected.Items.SortDescriptions(2).Direction = ComponentModel.ListSortDirection.Ascending
Looks like it would work. Intellisense says Direction is a getter and setter, but when I try to assign it to something I get the "Expression is a value and therefor cannot be the target of an assignment" error. By nature as a setter I should be able to assign this to a value, right? Any idea what's going wrong?
It appears as if SortDescriptions are boxed values.
Instead, try the following.
var sortDescription = grid.Items.SortDescriptions[0];
sortDescription.Direction = System.ComponentModel.ListSortDirection.Ascending;
grid.Items.SortDescriptions[0] = sortDescription;
so I am trying to assign a number to a variable that is dynically generated from a binded array...when i try and assign it and trace it out nothing happens, which means I am obviously doing something wrong but I am not sure? just for fun i decided to bind the data to a label like so...
<s:Label text="{this.dd.selectedViews.length}"/>
and that work and updated properly, but when running in debug mode i got this warning...
warning: unable to bind to property 'length' on class 'Array' (class is not an IEventDispatcher)
so what would be the best method of assigning the array to a variable to use throughout my application
thanks in advance for any help
I'm not really sure what you are asking here, but maybe this will help you out. As your error message says, the Array class is not an IEventDispatcher. What that means is that if you try to use a plain old Array as the source of a data-binding expression, it generally is not going to work.
If you need to bind to an array, you can try using a different class such as ArrayCollection, which supports data binding.
Here's the background for my question:
I would like to know if a particular System.Windows.Documents.AdornerLayer is empty or not.
"OK, I'll make the check myAdornerLayer.VisualChildrenCount > 0."
"Oh well, the property AdornerLayer.VisualChildrenCount is protected." (It overrides System.Windows.FrameworkElement.VisualChildrenCount which is also protected.)
"Hm... That won't stop me. I'll just access myAdornerLayer.VisualChildrenCount via reflection."
"On the other hand, maybe doing this will have some sort of bad side effect. Maybe VisualChildrenCount has been protected for a reason. I'll ask Stack Overflow".
If using reflection is a bad idea, do you have a suggestion for another way of finding out if an AdornerLayer is empty or not?
There is Visual Tree Helper class, that was made for this purpose..
http://bing.com/search?q=visualTreeHelper
is it possible to read the value of an IdentityTag if you place it on the TagVisualizer, without having initalized it before?
I would like to use the tags for registering a new object on the Surface but having all the "free" IdentityTags in a Collection for initalizing them all... There must be a better way to do in I think.
But the TagVisualizer doesn't seem to do anything when you put a tag on it that it doesn't know.
If I understand correctly, you'll need to start by setting up your TagVisualizer with a TagVisualizationDefinition with a Matches method that always returns true.