c# - Databinding not working on Avalondock window -
i have project window manager using avalondock.
basically there 2 element : layoutanchorableitem
show different tool box (currently one, consisting of treeview) , layoutitem
show document opened treeview (a custom control, bindable parameters - in theory)
the viewmodel of dockingmanager hosts observablecollection
named panes
layoutitems.
things works "fine" if don't try bind parameters in xaml, , force values this
<avalondock:dockingmanager.layoutitemtemplateselector> <panes:panestemplateselector> <panes:panestemplateselector.exchangeviewtemplate> <datatemplate> <xchng:exchange/> </datatemplate> </panes:panestemplateselector.exchangeviewtemplate> <panes:panestemplateselector.graphviewtemplate> <datatemplate> <grph:graph tickercode="ild" exchangecode="epa"/> </datatemplate> </panes:panestemplateselector.graphviewtemplate> </panes:panestemplateselector> </avalondock:dockingmanager.layoutitemtemplateselector>
exchange
toolbox , graph
layoutitems.
the initial databinding docking manager done :
<avalondock:dockingmanager margin="0,0,0,0" grid.row="1" anchorablessource="{binding tools}" documentssource="{binding panes}" activecontent="{binding activedocument, mode=twoway, converter={staticresource activedocumentconverter}}" x:name="dockmanager">
note pane of type graphviewmodel
has 2 public parameters : exchangecode
, tickercode
.
the thing want bind tickercode
, exchangecode
panes.tickercode , panes.exchangecode values.
so tried :
<grph:graph tickercode="{binding tickercode, updatesourcetrigger=propertychanged}" exchangecode="{binding exchangecode, updatesourcetrigger=propertychanged}"/>
but nothing : tickercode , exchangecode in custom control equal ""
contrary when force values in xaml.
also weird thing if step in code execution, panes
have values tickercode , exchangecode, don't bind. instance, code create pane is
public void addgraph(string fullname, string exchangecode, string tickercode) { var graphviewmodel = new graphviewmodel(fullname, exchangecode, tickercode); _panes.add(graphviewmodel); activedocument = graphviewmodel; }
here, every step has both values. , let's imagine add 5 different panes, correct exchangecode , tickercode, nothing passed custom control.
if need more info on custom control values bound to, here code : passing parameters custom control (databinding).
remark: see didn't put of code, make request if think may , add what's needed. note global logic of whole window manager same provided in avalondock test app (avalondock.mvvmtestapp).
for example, if i’ve got chartview , chartviewmodel: in mainwindow.xaml:
<xcad:dockingmanager x:name="dockingmanager" anchorablessource="{binding path=anchorables}" documentssource="{binding path=documents}" activecontent="{binding path=activedocument, mode=twoway, converter={staticresource activedocumentconverter}}"> <xcad:dockingmanager.layoutitemtemplateselector> <selfviewpane:panetemplateselector> <selfviewpane:panetemplateselector.chartviewtemplate> <datatemplate> <selfviewdocument:chartview /> </datatemplate> </selfviewpane:panetemplateselector.chartviewtemplate> </selfviewpane:panetemplateselector> </xcad:dockingmanager.layoutitemtemplateselector> <xcad:dockingmanager.layoutitemcontainerstyleselector> <selfviewpane:panestyleselector> <selfviewpane:panestyleselector.chartviewstyle> <style targettype="{x:type xcad:layoutitem}"> <setter property="title" value="{binding model.title}"/> <setter property="closecommand" value="{binding model.closecommand}"/> <setter property="iconsource" value="{binding model.iconsource}"/> <setter property="contentid" value="{binding model.contentid}"/> </style> </selfviewpane:panestyleselector.chartviewstyle> </selfviewpane:panestyleselector> </xcad:dockingmanager.layoutitemcontainerstyleselector> <xcad:dockingmanager.layoutupdatestrategy> <selfviewpane:layoutinitializer /> </xcad:dockingmanager.layoutupdatestrategy> <xcad:layoutroot> <xcad:layoutpanel orientation="horizontal"> <xcad:layoutanchorablepane name="toolspane" dockwidth="200"> </xcad:layoutanchorablepane> <xcad:layoutdocumentpane /> </xcad:layoutpanel> </xcad:layoutroot> </xcad:dockingmanager>
and: in chartviewmodel i’ve got property chartplotmodel:
/// <summary> /// gets or sets chartplotmodel. /// </summary> public plotmodel chartplotmodel { { return this.chartplotmodel; } set { if (this.chartplotmodel != value) { this.chartplotmodel = value; this.raisepropertychanged("chartplotmodel"); } } }
in chartview can bind:
<usercontrol x:class="jofta.analyzer.ui.classes.view.document.chartview" 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:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:oxy="http://oxyplot.org/wpf" mc:ignorable="d" d:designheight="300" d:designwidth="300"> <xctk:busyindicator isbusy="{binding path=isbusy}"> <grid> <oxy:plotview model="{binding chartplotmodel}" /> </grid> </xctk:busyindicator> </usercontrol>
in example i’m binding plotview oxyplot, think, can use pattern. you’ve got graphviewmodel, graphview , tickercode , exchangecode.
Comments
Post a Comment