WPF ListView item's Visible/Collaped not changing according to its Visibility -


thanks time reading thread.

i using vs2012, wfp, , .net4.5 on windows 7 64bit

i have listview control xaml in following:

<listview name="lvviewercontrol"                       selectionmode="single"                       selectedindex="{binding path=viewtype, mode=twoway, updatesourcetrigger=propertychanged}"                       background="{x:null}"                       borderbrush="{x:null}"                       margin="2">                 <label name="lblview2d"                        width="40"                        height="40"                        margin="3"                        background="#ff595959"                        foreground="white"                        horizontalcontentalignment="center"                        verticalcontentalignment="center">                     <image source="/capturesetupmodule;component/icons/2d.png" />                 </label>                 <label name="lblview3d"                        width="40"                        height="40"                        margin="3"                        background="#ff595959"                        foreground="white"                        horizontalcontentalignment="center"                        verticalcontentalignment="center">                     <image source="/capturesetupmodule;component/icons/3d.png" />                 </label>                 <label name="lblviewtiles"                                               width="40"                        height="40"                        margin="3"                        background="#ff595959"                        foreground="white"                        horizontalcontentalignment="center"                        verticalcontentalignment="center"                        visibility="{binding path=xyctrlvisible, mode=twoway, converter={staticresource booltovis}}">                     <image source="/capturesetupmodule;component/icons/tile.png" />                 </label>             </listview> 

now want collapse third item, lblviewtiles. tried combine visibility bool, bool visibility conversion, did not work. mean not work visiblity collapses when application starts (the application loads xml visibility starts). afterwards, not matter how binding variable (visiblity) changes, , value change collapsed, lblviewtiles still in listview control, no ui change.

here how datacontext binded: datacontex of listview binded capturesetupmodules class. listview defined in livevm class. action loading of xml in masterview class. in order access visibility property in capturesetupmodules, created capturesetupmodules object in masterview class,

in masterview class

    capturesetupmodules _capturevm = new capturesetupmodules();     ...  livevm _livevm = new livevm;       if (ndlist.count > 0)                 {                     xyborder.visibility = ndlist[0].attributes["visibility"].value.equals("visible") ? visibility.visible : visibility.collapsed;                     tilescontrolborder.visibility = ndlist[0].attributes["visibility"].value.equals("visible") ? visibility.visible : visibility.collapsed;                                    this.dispatcher.begininvoke(system.windows.threading.dispatcherpriority.normal,                        new action(                            delegate()                            {                                 _capturevm.xyctrlvisible = ndlist[0].attributes["visibility"].value.equals("visible") ? true:false;                             }                        )                    );                                } 

and here converter:

public sealed class booleantovisibilityconverter : ivalueconverter     {         public object convert(object value, type targettype, object parameter, cultureinfo culture)         {             var flag = false;             if (value bool)             {                 flag = (bool)value;             }             else if (value bool?)             {                 var nullable = (bool?)value;                 flag = nullable.getvalueordefault();             }             if (parameter != null)             {                 if (bool.parse((string)parameter))                 {                     flag = !flag;                 }             }             if (flag)             {                 return visibility.visible;             }             else             {                 return visibility.collapsed;             }         } 

this code makes item collapsed first time when application starts , , loads visibility xml file. afterwards, not matter how xyctrlvisible, visibility binding, changes, ui show no response. item there, or not there.

basically problem is: binded variable changes, xml file changes well, ui not change, exception first time when application launches loads xml.

it little messy here, let me know if need else. pretty confused myself too. thanks.

on property xyctrlvisible need implement inotifypropertychanged
how ui notified of changed

why binding 2 way?


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -