wpf - Binding default value to visibility if default value is null in ViewModel -


itemprop = "text">

The first time I want to be collapsing a text box while keeping one property (SomeProp) bound in my ViewModel Loading is.

Unfortunately I am not able to do this.

I have tried that:

Effort 1: I have tried clarity that the manufacturer of zero-view modal in price also clearly calls Onpropertychanged. The converter has not been triggered.

Effort 2: In the back code I have set the default visibility for visibility. Collapsed It seems to be a side effect that visibility is no longer bound to SomeProp property

Effort 3:. After googling I found something about PriorityBinding, but it seems to only work on the text property of the text box

Thanks in advance,

Additional information:

I have a text box and it should only be visible if a property (SomeProp) is in my ViewModel, one value 'Other' I am using a converter successfully for this. This means that whenever I change the value of SomeProp, the text box becomes visible / invisible based on the value of some PAP. I have used the following code.

Anyone know how I can set text box visibility to a property while keeping the binding for some property someProp

XAML

< Pre> & lt; Text box name = "txtbox" visibility = TextWrapping = "wrap" height = "150" MaxLength = "2000" text = "" {SomeProp.Description, converter = {StaticResource StringOtherToVisibilityConverter} binding} "{Binding SomeProp2.text, mode = Double} "scrollwire. VerticalScrollBarvival = "Auto" accepts return = "true" & gt; & Lt; / Text box & gt;

Class StringOtherToVisibilityConverter: System.Windows.Markup.MarkupExtension, IValueConverter {Public Object Convert (Object Value, Type TargetType, Object Parameter, System. Globalization. CultureInfo Culture) {If (value! = Null) {if (value.ToString () == "other") {Visit view. Visible; } And {return visibility. Collapsed; }} And {return visibility. Collapsed; }} Public Object Convertback (Object Value, Type Type, Object Parameter, System Globilization. Cultural Information Culture) {Return Null; //DependencyProperty.UnsetValue; } Public override object ProvideValue (IServiceProvider serviceProvider) {This refund; }}

setting TargetNullValue = {x: static visibility. Collapsed} binding target should collapse when the source value null

You can also set

FallbackValue , which is binding or conversion failed lives. In such failures, NullReferenceException may be included when XY will be bound if X is null .


Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -