targetnullvalue

Equiv. to Coalesce() in XAML Binding?

若如初见. 提交于 2020-01-10 19:41:09
问题 In SQL I can do this: Select Coalesce(Property1, Property2, Property3, 'All Null') as Value From MyTable If Property1, 2 and 3 are all null, then I get 'All Null' How do I do this in XAML? I tried the following, but no luck: <Window.Resources> <local:Item x:Key="MyData" Property1="{x:Null}" Property2="{x:Null}" Property3="Hello World" /> </Window.Resources> <TextBlock DataContext="{StaticResource MyData}"> <TextBlock.Text> <PriorityBinding TargetNullValue="All Null"> <Binding Path="Property1"

How to Set TargetNullValue to Visibility.Collapsed in Binding

心已入冬 提交于 2019-12-18 07:45:50
问题 I'm binding TextBlock.Visiblitiy to something, and I want to set the Binding.TargetNullValue to Collapsed , how can I do it in XAML? This one How do I set TargetNullValue to a date? does not work in Silverlight. (No x:Static ). 回答1: This is working for me in SL4: <TextBlock Text="Text" Visibility="{Binding Foo, TargetNullValue=Collapsed}"/> Where Foo: public Visibility? Foo { get; set; } 来源: https://stackoverflow.com/questions/8692862/how-to-set-targetnullvalue-to-visibility-collapsed-in

DataTemplate with TargetNullValue in a ListBox

微笑、不失礼 提交于 2019-12-18 06:55:06
问题 I have the following DataTemplate in a Listbox <ListBox Grid.Column="1" Grid.Row="2" ItemsSource="{Binding People}" SelectedItem="{Binding SelectedPerson}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock OverridesDefaultStyle="True" Background="{x:Null}" Margin="0" Padding="0" IsHitTestVisible="True" Text="{Binding TargetNullValue=None}" /> </DataTemplate> </ListBox.ItemTemplate> This works perfectly, displaying "None" in place of any Null (Nothing) values in the bound list. The problem is

How do I set TargetNullValue to a date?

妖精的绣舞 提交于 2019-12-10 13:52:44
问题 I'm using the WPF toolkit's Calendar control to allow users to select a date. If the date is not yet selected then the property the SelectedDate is bound to is Null. This makes the Calendar default you January 1, 0 AD. I'd like to do something like SelectedDate="{Binding UserPickedDate, TargetNullValue=Today, Mode=TwoWay}" But both "Today" and "Now" throw binding errors. Can I use TargetNullValue to set the default date to Today or Now? 回答1: Try this: xmlns:sys="clr-namespace:System;assembly

WPF Textblock TargetNullValue not working?

大憨熊 提交于 2019-12-07 03:09:44
问题 I have a wpf textblock as below: <TextBlock Text="{Binding [someViewModel].SomeVar.SomeSubVar.Name, TargetNullValue='-'}"/> At my viewmodel side, I'll have my own logic that in the end, SomeVar.SomeSubVar will be null. If I want to show a default value for this TextBlock I know I can declare and initiate SomeVar.SomeSubVar and assign default value into SomeVar.SomeSubVar.Name but I would like to use TargetNullValue instead. May I know which part is wrong? 回答1: You might look at using

WPF Textblock TargetNullValue not working?

血红的双手。 提交于 2019-12-05 07:53:38
I have a wpf textblock as below: <TextBlock Text="{Binding [someViewModel].SomeVar.SomeSubVar.Name, TargetNullValue='-'}"/> At my viewmodel side, I'll have my own logic that in the end, SomeVar.SomeSubVar will be null. If I want to show a default value for this TextBlock I know I can declare and initiate SomeVar.SomeSubVar and assign default value into SomeVar.SomeSubVar.Name but I would like to use TargetNullValue instead. May I know which part is wrong? You might look at using FallbackValue http://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.fallbackvalue(v=vs.110).aspx