c# - XAML Conditional Binding in DataTemplate -


I have a datatapplet for a list view in XAMML:

  & gt; Datamapplet X: Key = "ResultItemTemplate" & gt; & Lt; Grid grid. Column = "2" & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column width = "*" /> & Lt; Column width = "Auto" /> & Lt; /Grid.ColumnDefinitions> & Lt; Grid.RowDefinitions & gt; & Lt; RowDefinition Height = "Auto" /> & Lt; Roadfinion height = "*" /> & Lt; RowDefinition Height = "Auto" /> & Lt; /Grid.RowDefinitions> & Lt; Text block text = "{binding name}" margin = "0,10,20,0" grid. Column = "0" grid. Line = "0" /> & Lt; TextBlock Text = "{Binding Timestamp}" margin = "0,10,10,0" grid Column = "1" grid. Line = "0" /> & Lt; TextBlock Text = "{Binding Text}" Grid. Column = "0" grid. Colspan = "2" grid. Line = "1" texterprekking = "wrap" height = "auto" margin = "0,0,10, 10" /> & Lt; TextBlock Text = "{Binding Extra}" Grid. Column = "0" grid. Colspan = "2" grid. Line = "2" textwapping = "wrap" height = "auto" margin = "0,0,10, 20" /> & Lt; / Grid & gt; & Lt; / DataTemplate & gt;   

Then by applying this DataTemplate to my ListView, additional text blocks do not exist in every list item.

Although the space for additional text block exists, even if the databilling value is empty or not.
How do I get a text block when only 'additional' binding properties exist?

This is your converter:

  namespace value converters {public class } NullToVisibilityConverter: IValueConverter {Public Object Convert (Object Value, System.Type Target Type, Object Parameter, System.Globalization.CultureInfo Culture) {Return Value == Zero? Visibility Collapsed: Visibility. Visible; } Public Object Convertback (Object Value, SystemTip Target Type, Object Parameter, System Globilization. Cultural Information Culture) {Throw New System. Exceptions Exception (); }}}   

And this is your XML: place it in its original element:

  xmlns: conveters = "clr-namespace: valueconveters"   

and then in your resources:

  & lt; Candidate: Nalviviliability Converter x: key = "nullivobiliability canvar" /> & Lt; Datamapplet X: Key = "Resultsermalmetlate" & gt; & Lt; Grid grid. Column = "2" & gt; & Lt; Grid.ColumnDefinitions & gt; & Lt; Column width = "*" /> & Lt; Column width = "Auto" /> & Lt; /Grid.ColumnDefinitions> & Lt; Grid.RowDefinitions & gt; & Lt; RowDefinition Height = "Auto" /> & Lt; Roadfinion height = "*" /> & Lt; RowDefinition Height = "Auto" /> & Lt; /Grid.RowDefinitions> & Lt; Text block text = "{binding name}" margin = "0,10,20,0" grid. Column = "0" grid. Line = "0" /> & Lt; TextBlock Text = "{Binding Timestamp}" margin = "0,10,10,0" grid Column = "1" grid. Line = "0" /> & Lt; TextBlock Text = "{Binding Text}" Grid. Column = "0" grid. Colspan = "2" grid. Line = "1" texterprekking = "wrap" height = "auto" margin = "0,0,10, 10" /> & Lt; TextBlock Text = "{additional binding}" Visibility = "{binding excess, converter = {static resource nullivisibility corp}}" grid. Column = "0" grid. Colspan = "2" grid. Line = "2" textwapping = "wrap" height = "auto" margin = "0,0,10,20" /> & lt; / Grid & gt; & Lt; / DataTemplate & gt;    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -