Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Datatrigger Value Binding

42 views
Skip to first unread message

E

unread,
May 12, 2009, 4:39:01 PM5/12/09
to
I am trying to create a binding between two controls. I would like to change
a property on a control if it's value is the same as the value of another
control.

For instance, something like the following:

<Style TargetType="{x:Type xcdg:DataCell}">
<Setter Property="Background" Value="White" />
<Style.Triggers>
<DataTrigger Binding="{Binding lementName=BubblePointPressure, Path=Text}"
Value="{Binding Path=[OilPvtBubPtPres]}">
<Setter Property="Background" Value="LightBlue" />
</DataTrigger>
</Style.Triggers>
</Style>

But I get an error indicating I cannot place a Binding on a Value of a
Datatrigger.

Can someone suggest something else I might be able to do?


Ed Reyes

E

unread,
May 14, 2009, 7:19:01 PM5/14/09
to
ok, I have two of the three bindings. So I have the last two bindings
correct.

now, I am trying to get the first binding. i have been trying to use
different things.

I am trying to get to a Textbox on this Window that is bound to the desired
Domain Model DependencyProperty or I can go through the DataContext of the
Window.


<Style TargetType="{x:Type g:DataCell}">

<Setter Property="ReadOnly" Value="False" />

<Setter Property="Background" Value="White" />

<Style.Triggers>

<DataTrigger Value="True" >

<DataTrigger.Binding>

<MultiBinding Converter="{StaticResource equalsConverter}">

<Binding ElementName="BubblePointPressureTB" Path="Text"
diag:PresentationTraceSources.TraceLevel="High" />

<Binding Path="OilPvtBubPtPres"
diag:PresentationTraceSources.TraceLevel="High" />

<Binding RelativeSource="{RelativeSource Self}" Path="ParentColumn.Index"
diag:PresentationTraceSources.TraceLevel="High" />

</MultiBinding>

</DataTrigger.Binding>

<Setter Property="ReadOnly" Value="True" />

<Setter Property="Background" Value="AliceBlue" />

</DataTrigger>

</Style.Triggers>

</Style>

I get traceoutput of

: Created BindingExpression (hash=6310903) for Binding (hash=15717700)
within MultiBindingExpression (hash=35931636)

System.Windows.Data Warning: 54 : Path: 'Text'

System.Windows.Data Warning: 56 : BindingExpression (hash=6310903): Default
mode resolved to OneWay

System.Windows.Data Warning: 57 : BindingExpression (hash=6310903): Default
update trigger resolved to Explicit

System.Windows.Data Warning: 58 : BindingExpression (hash=6310903): Attach
to Xceed.Wpf.DataGrid.DataCell.NoTarget (hash=19645633)

System.Windows.Data Warning: 63 : BindingExpression (hash=6310903):
Resolving source

System.Windows.Data Warning: 66 : BindingExpression (hash=6310903): Found
data context element: <null> (OK)

System.Windows.Data Warning: 71 : Lookup name BubblePointPressureTB: queried
template of DataCell (hash=19645633)

System.Windows.Data Warning: 70 : Lookup name BubblePointPressureTB: queried
DataCell (hash=19645633)

System.Windows.Data Warning: 61 : BindingExpression (hash=6310903): Resolve
source deferred

<Binding ElementName="BubblePointPressureTB" Path="Text"
diag:PresentationTraceSources.TraceLevel="High" />

It appears that the above binidng is looking for the Textbox .Text in the
DataCell, how can I change the DataContext to look at the window not the
DataCell?

I would like to use something like this:

to get to the domain model object I would want to do something like this to
go through a DataContext
<Binding RelativeSource="{RelativeSource FindAncestor AncestorType={x:Type
local:TuneOil}}", Path="BubblePointPressure"
diag:PresentationTraceSources.TraceLevel="High" />
or to get to a TextBox on the TuneOil Screen, i would want to do something
like this.
<Binding RelativeSource="{RelativeSource FindAncestor AncestorType={x:Type
local:TuneOil}}", Path="BubblePointPressureTB"
diag:PresentationTraceSources.TraceLevel="High" />

but I cannot get the correct syntax. The Binding Markup is throwing me off.

0 new messages