wpf - Binding default value to visibility if default value is null in ViewModel -
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 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; }} & 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;
setting TargetNullValue = {x: static visibility. Collapsed} binding target should collapse when the source value null
You can also set
Comments
Post a Comment