Solved

Help with TargetType  - How do I selectivity set the targer to some and not others?

Posted on 2010-11-24
8
1,002 Views
Last Modified: 2013-11-12
Hi..
I have the following XAML... But I want to apply it some Paragraphs and not others how can I do that?
thanks

   
           
            <Style TargetType="Paragraph">
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="TextDecorations" Value="Underline" />
                    </Trigger>
                </Style.Triggers>
            </Style>


0
Comment
Question by:JElster
  • 4
  • 4
8 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34209694
When you need to customize behavior for certain paragraphs, then you need to know how to differentiate each Paragraph object.  One possible solution might be to store something in the Tag property that will let you identify the paragraph.
0
 
LVL 1

Author Comment

by:JElster
ID: 34209812
Ok.. I can add a TAG to the paragraphs... I'm creating the paragraphs in code.
How do I apply the above style to only those paragraphs  e.g  Tag like 'para_With_Formatting'?
thx
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34210532
The Trigger behavior is dependent on the Paragraph.IsMouseOver property.  Are you asking for a combination trigger with Paragraph.Tag?

For multiple conditions, you would need a MultiTrigger:

<MultiTrigger>
      <MultiTrigger.Conditions>
        <Condition Property="Content" Value="a" />
        <Condition Property="IsMouseOver" Value="True" />
      </MultiTrigger.Conditions>
      <Setter Property="Visibility" Value="Collapsed" />
</MultiTrigger>

Open in new window

0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:JElster
ID: 34212122
I want to trigger on only paragraphs that have a tag like 'para_with_formatting'
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 350 total points
ID: 34217704
<Trigger Property="IsMouseOver" Value="True">

     needs to become

<Trigger Property="Tag" Value="para_with_formatting">
0
 
LVL 1

Author Comment

by:JElster
ID: 34225240
I get the following message...

Error      5      'Tag' member is not valid because it does not have a qualifying type name.

  <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Tag" Value="paragraph_with_hyperlink" />
                    <Condition Property="IsMouseOver" Value="True" />
                </MultiTrigger.Conditions>
               <Setter Property="TextDecorations" Value="Underline" />
            </MultiTrigger>
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34227186
Did you figure out the conditions for the MultiTrigger?
0
 
LVL 1

Author Comment

by:JElster
ID: 34227210
Yes...
 <Style TargetType="{x:Type Paragraph}">
                 <Style.Triggers>
                    <MultiTrigger>
                        <MultiTrigger.Conditions>
                            <Condition Property="IsMouseOver" Value="True" />
                            <Condition Property="Tag" Value="paragraph_with_hyperlink" />
                        </MultiTrigger.Conditions>
                        <Setter Property="TextDecorations" Value="Underline" />
                        <Setter Property="Foreground" Value="Blue"/>
                    </MultiTrigger>
                </Style.Triggers>
            </Style>
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question