c# - WPF datagrid how to get access to the row click -


seems wpf application inherited has datagrid

<datagrid x:name="datagrid" itemssource="{binding alltroublecalls}" selectedindex="{binding selectedindex}"  

i want end setting background color yellow if textbox contains text in it.

the text appears when click on rows in datagrid

it seems based upon "binding"

  {binding ... }    

i have textbox added name it

<textbox tooltipservice.showduration="120000" tooltip="{binding threattext}" name="txtthreat" text="{binding threattext}"                    textwrapping="wrap" acceptsreturn="true"                   verticalscrollbarvisibility="visible" horizontalscrollbarvisibility="visible"                  margin="3" grid.row="8"  grid.column="1"                   grid.columnspan="3" grid.rowspan="1" isreadonly="true" height="30"/> 

show when in method can "test" , works

  txtthreat.background = new solidcolorbrush(colors.yellow);  

however, i'm not understanding why cannot handle on data changing whatever row clicked on in datagrid, data appears "magically" in many textboxes etc.. on xaml page.

i gather "binding" handling this, mvvm 2 way binding ?

i have tried plastering many breakpoints many methods can't seem of them show me how data changing on row click

there's little going on in question without details. however, can @ least answer think goal. easiest way textbox yellow if there's text in style:

    <textbox >         <textbox.style>             <style targettype="textbox">                 <setter property="background" value="yellow"></setter>                 <style.triggers>                     <trigger property="text" value="">                         <setter property="background" value="white"></setter>                     </trigger>                 </style.triggers>             </style>         </textbox.style>     </textbox> 

as figuring out how data changing... text displayed in textbox bound threattext. means text should change when property named threattext changed in class somewhere (your viewmodel). have tried putting breakpoint on setter threattext property? can put breakpoint on getter well. sounds when click in textbox/row, wpf updates text in ui, means it's reevaluating binding due change in threattext; means it'll hit getter... can check out stack trace if see what's going on.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -