wpf - Access objects dynamically set / created by Templates -


i began question here, doesn't seem concise enough.

i have datagrid bound object (job):

private string resultimagepath;  // image shown in datagrid showing status private string name;  // job container's name private string jobdescription; // sub task // , corresponding public properties implementing ipropertychange    public int sequence; // sorting purposses // paths icons  public string errorpath = "pack://application:,,,/resources/flag_red.ico"; public string successpath = "pack://application:,,,/resources/flag_green.ico"; public string warningpath = "pack://application:,,,/resources/flag_yellow.ico"; public string runningpath = "pack://application:,,,/resources/flag_running.ico"; public string historypath = "pack://application:,,,/resources/history.ico.ico"; 

when job object created gets resultimagepath set runningpath. jobs grouped using:

collection = new listcollectionview(jobdata); collection.groupdescriptions.add(new propertygroupdescription("name")); jobhistory.itemssource = collection; 

jobdata:

observablecollection<job> jobdata = new observablecollection<job>(); 

jobhistory datagrid using styles , templates:

<usercontrol.resources>     <image x:key="image" source="pack://application:,,,/resources/history.ico" height="18" width="18" margin="2,0"/>     <style x:key="groupheaderstyle" targettype="{x:type groupitem}">         <setter property="template">             <setter.value>                 <controltemplate targettype="{x:type groupitem}">                     <expander name="expander" isexpanded="true" >                         <expander.header>                             <stackpanel orientation="horizontal">                                 <contentcontrol content="{staticresource resourcekey=image}"/>                                 <textblock text="{binding name}" padding="2,0"/>                             </stackpanel>                         </expander.header>                         <itemspresenter />                     </expander>                 </controltemplate>             </setter.value>         </setter>     </style> </usercontrol.resources>  <datagrid name="jobhistory" canuseraddrows="false" autogeneratecolumns="false" columnwidth="*"           canuserdeleterows="false" itemssource="{binding}" grid.row="2"            grid.columnspan="5" canuserresizerows="false"            grid.rowspan="2" istextsearchenabled="true" verticalscrollbarvisibility="visible"  >     <datagrid.groupstyle>         <groupstyle containerstyle="{staticresource groupheaderstyle}">             <groupstyle.panel>                 <itemspaneltemplate>                     <datagridrowspresenter/>                 </itemspaneltemplate>             </groupstyle.panel>         </groupstyle>     </datagrid.groupstyle>     <datagrid.columns>         <datagridtemplatecolumn header="status" width="auto" isreadonly="true">             <datagridtemplatecolumn.celltemplate>                 <datatemplate>                     <image source="{binding resultimagepath}" height="18" width="18"/>                 </datatemplate>             </datagridtemplatecolumn.celltemplate>         </datagridtemplatecolumn>         <datagridtextcolumn header="job description" binding="{binding jobdescription}"/>     </datagrid.columns> </datagrid> 

when task's status has changed image changed running complete, warning or error. there can many jobs , groups differing stati.

sometask.resultimagepath = job.successpath; ... <datatemplate>   <image source="{binding resultimagepath}" height="18" width="18"/> </datatemplate> 

to point works well.

this question comes in:
how can set image of group header based on jobs being grouped? if job has errors or warnings group header's image should changed more serious. if jobs still running (but no errors or warnings), header should depict running. if jobs successful success image should shown. problem not logic, how access specific group header , modify image in stackbox.

for clarity's sake:

enter image description here

the warning image should replacing history image.

i wound adding image property job object. used "loaded" event search groups, , add "this" image job corresponding group.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -