c# - Why tooltip doesn't update it's content when binding changes? -
i have written following xaml code:
<window x:class="wpfapplication3.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="200" width="200"> <stackpanel> <listbox name="listbox"> <listboxitem content="item1" /> <listboxitem content="item2" /> <listboxitem content="item3" /> </listbox> <textblock datacontext="{binding elementname=listbox, path=selecteditem}" text="{binding content}" tooltip="{binding content}" /> <textblock datacontext="{binding elementname=listbox, path=selecteditem}" text="{binding content}"> <textblock.tooltip> <tooltip content="{binding content}"/> </textblock.tooltip> </textblock> </stackpanel> </window>
why first tooltip has same text it's parent textblock
, second never changes it's content when change selected item in listbox
?
in second example you're setting tooltip of textblock tooltip. set content of tooltip tooltip. these same first.
<textblock datacontext="{binding elementname=listbox, path=selecteditem}" text="{binding content}" tooltip="{binding content}" /> <textblock datacontext="{binding elementname=listbox, path=selecteditem}" text="{binding content}"> <textblock.tooltip> <binding path="content"/> </textblock.tooltip> </textblock>
and these pretty same last
<window.resources> <tooltip x:key="mytooltip" content="{binding content}"/> </window.resources> <textblock datacontext="{binding elementname=listbox, path=selecteditem}" text="{binding content}" tooltip="{binding source={staticresource mytooltip}}" /> <textblock datacontext="{binding elementname=listbox, path=selecteditem}" text="{binding content}"> <textblock.tooltip> <tooltip content="{binding content}"/> </textblock.tooltip> </textblock>
Comments
Post a Comment