wpf - Storing Image paths in XML and then returning image with query results -
wpf - Storing Image paths in XML and then returning image with query results -
i'm new development , so, i'm trying build little programme allow users search employee name , homecoming other info including staff photo.
building in wpf, c# code behind , staff details stored in xml file.
i can staff details xml searching need image returned can displayed in datatemplate results.
how best store info in xml , retrieve along search results?
thanks in advance.
mark
<window.resources> <datatemplate x:key="searchresultstemplate"> <grid margin="4,0,4,8" width="446" height="68"> <grid.columndefinitions> <columndefinition width="auto" /> <columndefinition width="*" /> </grid.columndefinitions> <border verticalalignment="top" margin="8" padding="2" background="white"> <image width="40" height="40" source="{binding path=avatar, mode=oneway}" /> </border> <stackpanel grid.column="1" verticalalignment="top" margin="0,4,0,0"> <textblock x:name="authorname" fontweight="bold" text="{binding path=author, mode=oneway}" /> <grid margin="0,6,0,0"> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition height="2" /> <rowdefinition height="auto" /> </grid.rowdefinitions> <textblock x:name="message" textwrapping="wrap" /> </grid> </stackpanel> </grid> </datatemplate> </window.resources> <scrollviewer horizontalscrollbarvisibility="disabled" verticalscrollbarvisibility="auto" borderthickness="1"> <itemscontrol x:name="searchresults" margin="0,8,0,0" grid.row="1" itemtemplate="{staticresource searchresultstemplate}" /> </scrollviewer>
code behind:
xdocument xdoc = xdocument.load("data.xml"); searchresults.itemssource = item in xdoc.descendants("item") (string)item.element("author") == searchinput select new { author = (string)item.element("author"), message = (string)item.element("message"), avatar = (string)item.element("avatar") };
wpf xml image
Comments
Post a Comment