How to have test data on Visual Studio 11 when using WPF and data binding? -
i have tab control data template renders data based on template , data on source bound to.
however, instantly makes ui development harder don't see in visual studio 11, because data comes when application running. there way add test data appears while working ui?
this tutorial msdn perfect: http://msdn.microsoft.com/en-us/library/ee823176.aspx
basically:
create file designdata/foodata/foo.xaml
content such as:
<local:foo xmlns:local="clr-namespace:yourproject" someproperty="sample" anotherproperty="bar" />
note foo
must class exists under namespace yourproject
properties used.
then select file solution explorer , set build action design data
.
add namespace mainwindow.xaml
code:
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
along other namespaces have.
then add top-level grid instance:
d:datacontext="{d:designdata source=./designdata/foodata/foo.xaml}"
now elements below grid element (under influence of datacontext) can have property:
<tabcontrol itemssource="{binding mode=oneway}">...
in case used tab control , data context collection designdata/foodata/foocollection.xaml
:
<local:foocollection xmlns:local="clr-namespace:yourproject"> <local:foo prop1="sample" prop2="test" /> ... </local:foocollection>
Comments
Post a Comment