Monday, 15 June 2015

c# - Is this exception caused by the dependency property? -



c# - Is this exception caused by the dependency property? -

i don't understand why exception when run app.

i've create dependency property in mainwindow class, , in imagesgrid class called on property.

i did not create changes in xaml. should have binded there too?

this code dependency propoerty:

public visibility buttonvisible { { homecoming (visibility)getvalue(buttonvisibleproperty); } set { setvalue(buttonvisibleproperty, value); } } public static readonly dependencyproperty buttonvisibleproperty = dependencyproperty.register("buttonvisible", typeof(visibility), typeof(mainwindow), new propertymetadata(false));

this phone call on property

if (selectedmodel winegroupmodel) { mainwindow wineswindow = new mainwindow(); //mainwindow wineswindow.buttonvisible = system.windows.visibility.hidden; //some code }

this constructor mainwindow

public mainwindow() { this.initializecomponent(); this.datacontext = this; imagesdir = @".\galleryimages"; }

this xaml code button:

<k:kinectcirclebutton style="{staticresource backbuttonstyle}" foreground="#511c74" name="backinectcirclebutton" label=""></k:kinectcirclebutton>

this image:

http://i60.tinypic.com/5zqt5.png

you have set wrong default value property, type visibility, not bool.

change declaration

public static readonly dependencyproperty buttonvisibleproperty = dependencyproperty.register( "buttonvisible", typeof(visibility), typeof(mainwindow), new propertymetadata(visibility.collapsed));

or leave out property metadata completely:

public static readonly dependencyproperty buttonvisibleproperty = dependencyproperty.register( "buttonvisible", typeof(visibility), typeof(mainwindow));

you bind visibility property of button property this:

<k:kinectcirclebutton ... visibility="{binding path=buttonvisible, relativesource={relativesource mode=findancestor, ancestortype=window}}" />

c# wpf xaml

No comments:

Post a Comment