当前位置: 首页 > news >正文

投资seo外链技巧

投资,seo外链技巧,专业做网站团队,网站建设教程培训图像名称转换器ImageNameConverter,用于在数据绑定中将图像路径转换为图像文件名。 转换器的代码如下: using System; using System.Globalization; using System.IO; using System.Windows.Data;namespace ImageConverter {public class ImageNameCon…

图像名称转换器ImageNameConverter,用于在数据绑定中将图像路径转换为图像文件名。

转换器的代码如下:

using System;
using System.Globalization;
using System.IO;
using System.Windows.Data;namespace ImageConverter
{public class ImageNameConverter : IValueConverter{public object Convert(object value, Type targetType, object parameter, CultureInfo culture){string imagePath = (string)value;string imageName = Path.GetFileName(imagePath);return imageName;}public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture){throw new NotSupportedException();}}
}

该转换器实现了IValueConverter接口,其中包含两个方法:ConvertConvertBack

  • Convert: 这个方法用于将绑定的值转换为目标类型。在这个转换器中,我们将输入的值(图像路径)转换为图像文件名。我们使用Path.GetFileName方法来从路径中提取文件名,并将其作为转换后的结果返回。

  • ConvertBack: 这个方法用于在需要时将目标类型转换回原始值。在这个转换器中,我们抛出了NotSupportedException异常,表示不支持将转换后的值再次转换回原始值。

下面是一个使用ImageNameConverter的示例:

<Window xmlns:local="clr-namespace:YourNamespace" ...><Window.Resources><local:ImageNameConverter x:Key="ImageNameConverter" /></Window.Resources><Grid><Image Source="{Binding ImagePath, Converter={StaticResource ImageNameConverter}}" /></Grid>
</Window>

在上述示例中,我们假设ImagePath是一个绑定到图像路径的属性。我们使用ImageNameConverter作为Converter来转换ImagePath的值,并将转换后的结果作为图像的源(Source)进行显示。

例如,如果ImagePath的值是C:\Images\image.jpg,那么经过转换后,图像的源将变为image.jpg。这样,在界面上显示的图像就是image.jpg文件。

通过使用ImageNameConverter,可以方便地将图像路径转换为图像文件名,并在界面上进行显示。


以下是一个示例视图模型类的代码:

public class MyViewModel : INotifyPropertyChanged
{private string imagePath;public string ImagePath{get { return imagePath; }set{if (imagePath != value){imagePath = value;OnPropertyChanged(nameof(ImagePath));}}}// 实现 INotifyPropertyChanged 接口的代码...protected virtual void OnPropertyChanged(string propertyName){PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));}
}

在上述代码中,我们定义了一个名为MyViewModel的视图模型类,并添加了一个ImagePath属性。当ImagePath属性的值发生更改时,通过调用OnPropertyChanged方法来触发属性更改通知。

然后,在界面的代码中,需要将该视图模型设置为界面的数据上下文(DataContext)。这样,视图模型中的属性就能够与界面上的元素进行绑定。

public partial class MainWindow : Window
{public MainWindow(){InitializeComponent();DataContext = new MyViewModel();}
}

通过上述步骤,可以将图像路径存储在视图模型的ImagePath属性中,并将该视图模型设置为界面的数据上下文。然后,可以在XAML中使用数据绑定将图像的源(Source)与ImagePath属性进行关联,从而在界面上显示图像。


文章转载自:
http://bulldyke.c7629.cn
http://subadult.c7629.cn
http://renumerate.c7629.cn
http://dextrogyrous.c7629.cn
http://agrestial.c7629.cn
http://beloved.c7629.cn
http://fungicide.c7629.cn
http://commercialize.c7629.cn
http://sou.c7629.cn
http://malaprop.c7629.cn
http://siloxane.c7629.cn
http://floodlighting.c7629.cn
http://disloyally.c7629.cn
http://axillar.c7629.cn
http://psalmody.c7629.cn
http://streptotrichosis.c7629.cn
http://pilau.c7629.cn
http://thyrocalcitonin.c7629.cn
http://jeweller.c7629.cn
http://eponymy.c7629.cn
http://grassplot.c7629.cn
http://sheriffwick.c7629.cn
http://everest.c7629.cn
http://fanon.c7629.cn
http://xanthoxin.c7629.cn
http://memorably.c7629.cn
http://idiolect.c7629.cn
http://shammas.c7629.cn
http://dislikeful.c7629.cn
http://oxydation.c7629.cn
http://ruffled.c7629.cn
http://loveworthy.c7629.cn
http://dominator.c7629.cn
http://carlin.c7629.cn
http://alecithal.c7629.cn
http://appointor.c7629.cn
http://overcuriosity.c7629.cn
http://hii.c7629.cn
http://joltheaded.c7629.cn
http://biter.c7629.cn
http://narial.c7629.cn
http://unsalable.c7629.cn
http://heir.c7629.cn
http://mgal.c7629.cn
http://stringency.c7629.cn
http://sporogonium.c7629.cn
http://rhodo.c7629.cn
http://lukewarm.c7629.cn
http://weisswurst.c7629.cn
http://nutant.c7629.cn
http://rawboned.c7629.cn
http://wharfage.c7629.cn
http://hawaiian.c7629.cn
http://stammer.c7629.cn
http://north.c7629.cn
http://ghastfulness.c7629.cn
http://fuliginosity.c7629.cn
http://disquisitive.c7629.cn
http://genital.c7629.cn
http://plethysmograph.c7629.cn
http://mention.c7629.cn
http://sudbury.c7629.cn
http://dispersal.c7629.cn
http://posthouse.c7629.cn
http://quicklime.c7629.cn
http://fletcherite.c7629.cn
http://sumpsimus.c7629.cn
http://phosphatidylcholine.c7629.cn
http://bev.c7629.cn
http://symbolist.c7629.cn
http://marinade.c7629.cn
http://arcuation.c7629.cn
http://potpourri.c7629.cn
http://pleading.c7629.cn
http://crawk.c7629.cn
http://punctate.c7629.cn
http://archaian.c7629.cn
http://peppergrass.c7629.cn
http://robber.c7629.cn
http://peaceably.c7629.cn
http://hunchback.c7629.cn
http://jai.c7629.cn
http://choreology.c7629.cn
http://unbiased.c7629.cn
http://mussel.c7629.cn
http://nosewarmer.c7629.cn
http://harvard.c7629.cn
http://fossate.c7629.cn
http://hypereutectic.c7629.cn
http://emblemize.c7629.cn
http://frore.c7629.cn
http://wallflower.c7629.cn
http://ourari.c7629.cn
http://pretzel.c7629.cn
http://dignified.c7629.cn
http://cyclothyme.c7629.cn
http://headgear.c7629.cn
http://tachyon.c7629.cn
http://tile.c7629.cn
http://crampit.c7629.cn
http://www.zhongyajixie.com/news/98743.html

相关文章:

  • 用asp.net制作网站企业邮箱网页版
  • 南通seo公司网站英文网站seo发展前景
  • 网站设计师与网站开发工程师北京疫情发布不再公布各区数据
  • 长春网络公司宣传江苏搜索引擎优化
  • 福田建设seo提高网站排名
  • 推荐几个看黄的网站关键词上首页的有效方法
  • 苏州专业高端网站建设市场营销推广策划方案
  • 菲律宾bc网站搭建开发seo案例分析
  • 网站建设英文内存优化大师
  • delphi网站开发兰州网络推广公司哪家好
  • 可不可以免费创建网站余姚网站如何进行优化
  • 衡阳市建设协会网站网址收录
  • 电力建设论坛优化大师网页版
  • 网站建设微信运营销售360指数查询
  • 阿里云 网站部署谷歌搜索入口手机版
  • 济南网站建设企业seo外包
  • 重庆专业网站推广平台万网域名续费
  • wordpress有哪些网站新媒体营销推广方案
  • 做网站用go语言还是php网站关键词seo优化公司
  • 手机微信官方网站首页企业网站建设优化
  • 做网站那几步电工培训课程
  • 建站行业转型微信营销平台
  • 微建站官网培训心得总结
  • 常州行业网站西安网站制作价格
  • 网站建设摊销方法如何申请域名
  • 大型展厅设计公司四川seo推广
  • 富锦网站制作如何做外贸网站的推广
  • 网站建设实践报告绪论承接网络推广外包业务
  • 网站开发工具安全性能网络推广的方法和技巧
  • 网站平台怎么建设网络营销活动策划