Step1: 下载地址为:/
Step2:复制 f 字体到项目中,并在字典中引用该字体
字典中引用字体
<FontFamily x:Key="FontAwesome">pack://application:,,,/MafengWo;component/Fonts/#FontAwesome</FontFamily>
如取f110
安装 PropertyChanged.Fody NuGet 软件包并更新Fody NuGet包:
Install-Package Fody
Install-Package PropertyChanged.Fody
这个Install-Package Fody这是必需的,因为NuGet总是默认为任何依赖项的最古老和最错误的版本。
加到l
<Weavers><PropertyChanged/>
</Weavers>
特别提醒:VS2017 安装2.61 版本
方法同 PropertyChanged.Fody
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"><Costura /><PropertyChanged/>
</Weavers>
[AddINotifyPropertyChangedInterface]
public class BaseViewModel : INotifyPropertyChanged
{public event PropertyChangedEventHandler PropertyChanged = (sender, e) => { };public void OnPropertyChanged(string name){PropertyChanged(this, new PropertyChangedEventArgs(name));}
}
所有 ViewModel 全部继承自 BaseViewModel
该基类实现了 [AddINotifyPropertyChangedInterface] 接口,这样在编译的时候将PropertyChanged方法植入到public属性的Set方法中,这样就不必为每个Set都写PropertyChanged了
public class BasePage<VM> : Pagewhere VM :BaseViewModel,new ()
{#region private Member/// <summary>/// The view Model associated with this page/// </summary>private VM mViewModel;#endregion#region Properties/// <summary>/// The animition the play when the page is first loaded/// </summary>public PageAnimation PageLoadAnimation { get; set; } = PageAnimation.SlideAndFadeInFromRight;/// <summary>/// The animition the play when the page is first unloaded/// </summary>public PageAnimation PageUnLoadAnimation { get; set; } = PageAnimation.SlideAndFadeInFromLeft;/// <summary>/// The time to Animation takes complete/// </summary>public float SlideSeconds { get; set; } = 0.8f;/// <summary>/// The view Model associated with this page/// </summary>public VM ViewModel{get{return mViewModel;}set{//if nothing has changed ,returnif (mViewModel == value)return;//Update the valuemViewModel = value;//Set data contenxt for this pagethis.DataContext = mViewModel;}}#endregion#region Constructorpublic BasePage(){if (PageLoadAnimation != PageAnimation.None)Visibility = Visibility.Collapsed;//Listen out for page loadingLoaded += BasePage_Loaded;//Create a default view modelthis.ViewModel = new VM();}#endregion#region Animation Load / Unload/// <summary>/// Once the page is loaded ,perform any requied animation/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private async void BasePage_Loaded(object sender, System.Windows.RoutedEventArgs e)// use void {await AmimationIn();}public async Task AmimationIn(){if (PageLoadAnimation == PageAnimation.None)return
本文发布于:2024-01-31 20:04:15,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170670265531027.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |