data binding - How to set databinding property to textblock in wpf usercontrol? -
<textblock margin="0,109,20,0" verticalalignment="top" height="auto" textwrapping="wrap" fontweight="bold" fontsize="14" horizontalalignment="right" foreground="#ff575757" rendertransformorigin="-3.611,3.696" cliptobounds="true" text="---------------------" width="213"/>
this xaml textblock code part of usercontrol ui element.
how databinding this?
when try put
text="{binding clickcount1, elementname=myusercontrol, mode=default}
the xaml giving errors , design view become invisible.
pls help.
i think want
usercontrol example
<usercontrol x:class="wpfapplication1.myusercontrol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:wpfapplication1" mc:ignorable="d" d:designheight="300" d:designwidth="300"> <grid> <textblock name="clickcount1" text="12" /> </grid> </usercontrol>
window example using user control binding
<window x:class="wpfapplication1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:wpfapplication1" mc:ignorable="d" title="mainwindow" height="350" width="525"> <grid> <grid.rowdefinitions> <rowdefinition /> <rowdefinition /> </grid.rowdefinitions> <local:myusercontrol x:name="myusercontrol" /> <textblock grid.row="1" text="{binding elementname=myusercontrol.clickcount1, path=text}" /> </grid> </window>
Comments
Post a Comment