When we write pages on the front-end, sometimes the data provided to us by the backend is not ready for use. We need to convert the data for use. Therefore, we need to create a front-end Data Conversion Tool class
Using System; Using System. Collections. Generic; Using System. LINQ; Using System. text; Using System. Threading. tasks; Using Windows. UI. XAML; Using Windows. UI. XAML. Data; Namespace Gridexp { Public Class Boolvisibilityconverter: ivalueconverter { Public Object Convert ( Object Value, type targettype, Object Parameter, String Language ){ // Value is the data in the model, and the returned value is the data in the UI after conversion. Bool B = ( Bool ) Value; Return B? Visibility. Visible: visibility. collapsed ;} Public Object Convertback ( Object Value, type targettype, Object Parameter, String Language ){ // Value is the value of the data type in the UI into the model (twoway binding) Visibility v =(Visibility) value; Return V = Visibility. visible ;}}}
REFERENCE The namespace of the class in the first tag.
< Common: layoutawarepage X: Name = "Pageroot" X: Class = "Gridexp. groupeditemspage" Datacontext =" {Binding defaviewviewmodel, relativesource = {relativesource self }} " Xmlns = "Http://schemas.microsoft.com/winfx/2006/xaml/presentation" Xmlns: x = "Http://schemas.microsoft.com/winfx/2006/xaml" Xmlns: Local= "Using: gridexp" Xmlns: Data = "Using: gridexp. Data" Xmlns: Common = "Using: gridexp. Common" Xmlns: d = "Http://schemas.microsoft.com/expression/blend/2008" Xmlns: MC = "Http://schemas.openxmlformats.org/markup-compatibility/2006" MC: ignorable = "D" >
Set another resource, which is equivalent to a new object in this page.
<Page. Resources><! --The set of group items displayed on this page is bound to the subset of the full item list because the items in the virtualization group cannot be--><Local: boolvisibilityconverterX: Key= "Boovisconverter"> </Local: boolvisibilityconverter>
Finally, use
<ImageSource= "Images/w_mengchong.jpg"Visibility="{Binding isunmem, converter = {staticresource boovisconverter }}"Width= "50"Height= "50"> </Image>