473,772 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting an attached property by a Setter element?

I have the fragment below as contents of a <Gridelement. The idea is that
if the checkbox is checked the <TreeViewelemen t 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="{B inding Path=BlasRoot.C hildren}" d:LayoutOverrid es="Width"
Margin="0,0,0,8 " Grid.Column="0" Grid.ColumnSpan ="2">

<TreeView.Style >

<Style>

<Style.Triggers >

<DataTrigger Binding="{Bindi ng ElementName=chk Position,
Path=IsChecked} " Value="True">

<Setter Property="Grid. ColumnSpan" Value="1"/>

<Setter Property="TreeV iew.Background" Value="Red"/>

</DataTrigger>

</Style.Triggers>

</Style>

</TreeView.Style>

</TreeView>

<CheckBox HorizontalAlign ment="Left" Margin="-50,0,0,0" x:Name="chkPosi tion"
VerticalAlignme nt="Top" Content="CheckB ox">

</CheckBox>


Feb 10 '07 #1
4 2601
Hi Henrik,

This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.

Sincerely,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 12 '07 #2
Hello Walter,

Thank you very much. I look forward for further information.
Best regards,

Henrik Dahl

"Walter Wang [MSFT]" <wa****@online. microsoft.comsk rev i en meddelelse
news:nr******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Henrik,

This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.

Sincerely,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your
reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no
rights.

Feb 12 '07 #3
Hi Henrik,

The problem is that that property is also being set on the TreeView itself.
When a property is specified directly on an element, and on the element's
style, the conflict resolution gives precedence to the value on the
element. I.e., a local value wins over a style value.

You could find more information here:

#Dependency Property Value Precedence
http://msdn2.microsoft.com/en-us/library/ms743230.aspx
To fix it, we need to remove the Grid.ColumnSpan attribute in the TreeView
element and set it using a Setter:

<TreeView
x:Name="Blas"
ItemsSource="{B inding Path=BlasRoot.C hildren}"
d:LayoutOverrid es="Width"
Margin="0,0,0,8 " Grid.Column="0" >
<TreeView.Style >
<Style>
<Setter Property="Grid. ColumnSpan" Value="2" />
Hope this helps.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 13 '07 #4
Hello Walter,

Thank you very much for your assitance, as always! I must say that I did not
know that the attribute on the TreeView element also takes precedence over
the style when the style is applied after construction. I thought it just
took precedence over during the construction phase.
Best regards,

Henrik Dahl

"Walter Wang [MSFT]" <wa****@online. microsoft.comsk rev i en meddelelse
news:7S******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Henrik,

The problem is that that property is also being set on the TreeView
itself.
When a property is specified directly on an element, and on the element's
style, the conflict resolution gives precedence to the value on the
element. I.e., a local value wins over a style value.

You could find more information here:

#Dependency Property Value Precedence
http://msdn2.microsoft.com/en-us/library/ms743230.aspx
To fix it, we need to remove the Grid.ColumnSpan attribute in the TreeView
element and set it using a Setter:

<TreeView
x:Name="Blas"
ItemsSource="{B inding Path=BlasRoot.C hildren}"
d:LayoutOverrid es="Width"
Margin="0,0,0,8 " Grid.Column="0" >
<TreeView.Style >
<Style>
<Setter Property="Grid. ColumnSpan" Value="2" />
Hope this helps.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no
rights.

Feb 13 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4110
by: kepes.krisztian | last post by:
Hi ! I want to create a property that can use parameter(s). In Delphi I can create same thing (exm: Canvas.Pixel -> Canvas.GetPixel(self,X,Y):integer; Canvas.SetPixel(self,X,Y,Color::integer); class A(object): def __init__(self): self.__Tags={} def GetTag(self,tname):
5
2211
by: Jason Butera | last post by:
I know that I can read/write custom properties of an object by using the following: Setting: document.all.customProp = "this"; Getting: document.all.customProp; Is there a way I can run code when this custom property is set. Or perhaps there is a way to create a custom method?
9
1996
by: Michael Roper | last post by:
If a class uses public properties to expose private fields, and has a constructor to initialize those fields, should the constructor set them directly or use the set accessors? Or does it matter? Michael Roper
8
2266
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing happens. dim filt as string ... build filter string... UserControl.ReportFilter = filt
3
1488
by: Tina | last post by:
(on the prior message the code snippet was wrong. this is the one that executes the set in a loop until a stack overflow occurrs) (using 1.1) I have the following property defined in an ascx control. public string Title //property { get {return this.Title; }
3
1464
by: Patient Guy | last post by:
Subject line would seem to say it all: How does one trigger the execution of a method within an object or any other code/function with the setting of an object property? More elaboration for those who want it: Suppose we have anObjectType, with a property .description, whose value can be a string, and the value of .description actually describes the
11
4180
by: Eran.Yasso | last post by:
Hi All, this issue curious me for long time. Any one knows why Microsoft didn't allow to different access modifier for set and get? To be more specific, why didn't they allow us to do it like this? static string CSVFileName { public get { return _CSVFileName; }
41
2886
by: Jim | last post by:
Hi guys, I have an object which represents an "item" in a CMS "component" where an "item" in the most basic form just a field, and a "component" is effectively a table. "item" objects can be created and then added to "component" objects to build up the component definition. My dilemma comes in deciding how to read/write data to the "item"
1
11746
by: DeanB | last post by:
Please excuse my ignorance here as I have not used WPF for long, but what is the statement that tells what the "local:" identifier is that allows a window event to call a function in a .cs file? Here is the top of a window definition in xaml: I've marked the area in question with ?????. I have to call the TypeDirectoryValidationRule function from within the xaml code. I'm also confused on what the "SomePath" string is supposed to be for....
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9911
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.