473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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 <TreeViewelement 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="CheckBox">

</CheckBox>


Feb 10 '07 #1
4 2584
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.comskrev i en meddelelse
news:nr**************@TK2MSFTNGHUB02.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="{Binding Path=BlasRoot.Children}"
d:LayoutOverrides="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.comskrev i en meddelelse
news:7S**************@TK2MSFTNGHUB02.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="{Binding Path=BlasRoot.Children}"
d:LayoutOverrides="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
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); ...
5
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...
9
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?...
8
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...
3
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...
3
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...
11
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...
41
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...
1
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? ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.