-
- ExtZGholson
- Posts: 22
- Joined:
Initialize DependencyProperty when declaring component?
Hello,
I am currently have a component that we declare by doing the following:
BackVisible is an NsProp bool and the CenterText is a Noesis::String.
I would like to be able to be able to bind these values on our view in some cases while giving a explicit value in other cases.
In that case, we would have both
and
In order to bind it, we would need to utilize the DependencyProperty. However, I believe that the value of the DependencyProperty is set to the default value when we try to use the explicit declaration in Example A.
This code would make Back Visible even in Example A.
Am I going about this the wrong way or do we have a suggestion on how to do this?
Thank you,
Zane
I am currently have a component that we declare by doing the following:
Code: Select all
<components:BasicUI
x:Name="BasicUIBackground"
BackVisible="False"
CenterText="Insert Text Here"
PrivacyVisible="False" />I would like to be able to be able to bind these values on our view in some cases while giving a explicit value in other cases.
In that case, we would have both
Code: Select all
"Example A"
<components:BasicUI
x:Name="BasicUIBackground"
BackVisible="False"
CenterText="Insert Text Here"
PrivacyVisible="False" />Code: Select all
"Example B"
<components:BasicUI
x:Name="BasicUIBackground"
BackVisible="{Binding signup.isOnConsole}"
CenterText="{Binding Descriptor}"
PrivacyVisible="True" />Code: Select all
data->RegisterProperty<bool>(dpBackVisible, "BackVisible", Noesis::PropertyMetadata::Create(bool(true)));Am I going about this the wrong way or do we have a suggestion on how to do this?
Thank you,
Zane
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Initialize DependencyProperty when declaring component?
Hi Zane, as you mentioned only DependencyProperties can be used for bindings so you should use them in that scenario.
The default value of a dependency property is only used if the value is not set from any other source (explicit local value, style setter, trigger setter...).
In example A, as you are locally setting the value of the property, that will be the effective value used, not the default one. Isn't that working for you as expected?
The default value of a dependency property is only used if the value is not set from any other source (explicit local value, style setter, trigger setter...).
In example A, as you are locally setting the value of the property, that will be the effective value used, not the default one. Isn't that working for you as expected?
-
- ExtZGholson
- Posts: 22
- Joined:
Re: Initialize DependencyProperty when declaring component?
Thank you, it does seem to work in some cases and in another case it just seems inconsistent. Allow me to see if I can isolate when and why it doesn't respect the properties.
-
- ExtZGholson
- Posts: 22
- Joined:
Re: Initialize DependencyProperty when declaring component?
It appears that everything is working as intended. Thanks again!
-
-
sfernandez
Site Admin
- Posts: 3363
- Joined:
Re: Initialize DependencyProperty when declaring component?
Ok, thanks for the confirmation.
Who is online
Users browsing this forum: No registered users and 2 guests