Click here to Skip to main content
15,888,984 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Conditional DataBinding to UI Elements Pin
Mycroft Holmes4-Feb-12 17:00
professionalMycroft Holmes4-Feb-12 17:00 
GeneralRe: Conditional DataBinding to UI Elements Pin
Andy_L_J4-Feb-12 17:48
Andy_L_J4-Feb-12 17:48 
GeneralRe: Conditional DataBinding to UI Elements Pin
Mycroft Holmes4-Feb-12 21:04
professionalMycroft Holmes4-Feb-12 21:04 
GeneralRe: Conditional DataBinding to UI Elements Pin
Andy_L_J4-Feb-12 22:05
Andy_L_J4-Feb-12 22:05 
GeneralRe: Conditional DataBinding to UI Elements Pin
Mycroft Holmes5-Feb-12 0:58
professionalMycroft Holmes5-Feb-12 0:58 
GeneralRe: Conditional DataBinding to UI Elements Pin
SledgeHammer015-Feb-12 7:53
SledgeHammer015-Feb-12 7:53 
GeneralRe: Conditional DataBinding to UI Elements Pin
Mycroft Holmes5-Feb-12 11:01
professionalMycroft Holmes5-Feb-12 11:01 
GeneralRe: Conditional DataBinding to UI Elements Pin
SledgeHammer015-Feb-12 11:49
SledgeHammer015-Feb-12 11:49 
Here is part of one I wrote for a custom control. It's not a one liner obviously because it's more complicated, but its setting the visibility based on *4* conditions Smile | :) .

XML
<DataTemplate.Triggers>
    <MultiDataTrigger>
        <MultiDataTrigger.Conditions>
            <Condition Value="1">
                <Condition.Binding>
                    <MultiBinding Converter="{StaticResource HeaderArrowConverter}">
                        <Binding RelativeSource="{RelativeSource Mode=TemplatedParent}" />
                        <Binding Path="View.AllowsSorting" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ctrls:ListViewEx}" />
                        <Binding Path="View.SortColumn" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ctrls:ListViewEx}" />
                        <Binding Path="View.SortDirection" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ctrls:ListViewEx}" />
                    </MultiBinding>
                </Condition.Binding>
            </Condition>
        </MultiDataTrigger.Conditions>
        <MultiDataTrigger.Setters>
            <Setter TargetName="arrow" Property="Data" Value="{StaticResource HeaderArrowUp}" />
            <Setter TargetName="arrow" Property="Visibility" Value="Visible" />
        </MultiDataTrigger.Setters>
    </MultiDataTrigger>


When the value is returned as 1 from the converter, that trigger executes. I haven't had a case where I have to handle a range of values in one trigger, but I have seen some solutions online for that. Instead of having just "1", you can have something like "> 1 && < 5" or however they specify it.

A simple "one liner":

XML
<Trigger Property="SomeProp" Value="15">
    <Setter Property="Visibility" Value="Collapsed" />
</Trigger>


modified 5-Feb-12 18:21pm.

GeneralRe: Conditional DataBinding to UI Elements Pin
Mycroft Holmes5-Feb-12 12:15
professionalMycroft Holmes5-Feb-12 12:15 
GeneralRe: Conditional DataBinding to UI Elements Pin
SledgeHammer015-Feb-12 12:26
SledgeHammer015-Feb-12 12:26 
GeneralRe: Conditional DataBinding to UI Elements Pin
Mycroft Holmes5-Feb-12 13:15
professionalMycroft Holmes5-Feb-12 13:15 
GeneralRe: Conditional DataBinding to UI Elements Pin
SledgeHammer015-Feb-12 14:14
SledgeHammer015-Feb-12 14:14 
GeneralRe: Conditional DataBinding to UI Elements Pin
Mycroft Holmes5-Feb-12 15:15
professionalMycroft Holmes5-Feb-12 15:15 
AnswerRe: Conditional DataBinding to UI Elements Pin
Mycroft Holmes5-Feb-12 15:16
professionalMycroft Holmes5-Feb-12 15:16 
GeneralRe: Conditional DataBinding to UI Elements Pin
Andy_L_J5-Feb-12 15:43
Andy_L_J5-Feb-12 15:43 
QuestionOwn TreeViewItem with image and text Pin
Mc_Topaz2-Feb-12 22:20
Mc_Topaz2-Feb-12 22:20 
AnswerRe: Own TreeViewItem with image and text Pin
Mc_Topaz3-Feb-12 0:52
Mc_Topaz3-Feb-12 0:52 
GeneralGridSplitter Conundrum Pin
Gil Yoder1-Feb-12 15:31
Gil Yoder1-Feb-12 15:31 
QuestionRe: GridSplitter Conundrum Pin
Gil Yoder2-Feb-12 9:44
Gil Yoder2-Feb-12 9:44 
AnswerRe: GridSplitter Conundrum Pin
SledgeHammer012-Feb-12 11:40
SledgeHammer012-Feb-12 11:40 
GeneralRe: GridSplitter Conundrum Pin
Gil Yoder2-Feb-12 14:09
Gil Yoder2-Feb-12 14:09 
GeneralRe: GridSplitter Conundrum Pin
SledgeHammer012-Feb-12 14:37
SledgeHammer012-Feb-12 14:37 
GeneralRe: GridSplitter Conundrum Pin
Gil Yoder2-Feb-12 15:43
Gil Yoder2-Feb-12 15:43 
SuggestionRe: GridSplitter Conundrum Pin
Gil Yoder2-Feb-12 18:59
Gil Yoder2-Feb-12 18:59 
GeneralRe: GridSplitter Conundrum Pin
SledgeHammer013-Feb-12 7:17
SledgeHammer013-Feb-12 7:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.