1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > styles

styles

时间:2022-11-20 20:17:09

相关推荐

styles

```csharp<?xml version="1.0" encoding="utf-8" ?><Application xmlns="/schemas//forms"xmlns:x="/winfx//xaml"xmlns:appstyles="clr-namespace:AppForm.Styles"x:Class="AppForm.App"><!--Define global resources and styles here, that apply to all pages in your app.--><Application.Resources><ResourceDictionary Source="Styles/ColorStyle.xaml"><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="Styles/ButtonStyle.xaml"></ResourceDictionary><appstyles:TabStyle></appstyles:TabStyle></ResourceDictionary.MergedDictionaries></ResourceDictionary> </Application.Resources></Application>

```csharp<?xml version="1.0" encoding="UTF-8"?><ResourceDictionary xmlns="/schemas//forms" xmlns:x="/winfx//xaml"x:Class="AppForm.Styles.TabStyle"></ResourceDictionary>

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using Xamarin.Forms;using Xamarin.Forms.Xaml;namespace AppForm.Styles{[XamlCompilation(pile)]public partial class TabStyle : ResourceDictionary{public TabStyle(){InitializeComponent();}}}

Step 1:Create a ContentPage or ContentView file in the solution and give the file name like this. -> MyInnerResourceDictionary.xaml.1.1: Remove the code behind file.1.2: in the XAML file change the name of the base class from ContentView or ContentPage to ResourceDictionary. In addition, remove the x:Class attribute from the root tag of the file.Step 2:Consume Resource Dictionary file in the MainPage.xaml [Check Source Code].If we want to develop external style inside the .Net standard Class library.Step 3:Create .Net Standard Class Library. 3.1 Select the solution and Unload the Project.3.2 Select the solution and Edit Project file.3.3 Add the following reference in the .csproj file project.<ItemGroup><PackageReference Include="Xamarin.Forms" Version="4.8.0.1451" /><PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" /></ItemGroup>3.4 Create a ContentPage or ContentView file in the solution and give the file name like this. -> MyOuterResourceDictionary.xaml [Check Source Code]Do not remove the code behind file.in the XAML file change the name of the base class from ContentView or ContentPage to ResourceDictionary. add x:Class attribute from the root tag of the file.Step 4:Add the project refereance in Main the Solution.Step 5:Go to MainPage.xaml file.5.1 Add the external style referance in root tagxmlns:mystyles="clr-namespace:StylesLib.MyStyles;assembly=StylesLib"5.2Using Merge Dictionary call the external style referance<ContentPage.Resources><!--Internal Style--><ResourceDictionary Source="RootStyles/MyInnerResourceDictionary.xaml"><!--For External Library--><ResourceDictionary.MergedDictionaries><mystyles:MyOuterResourceDictionary></mystyles:MyOuterResourceDictionary></ResourceDictionary.MergedDictionaries></ResourceDictionary></ContentPage.Resources>

<Project Sdk=".Sdk"><PropertyGroup><TargetFramework>netstandard2.0</TargetFramework><ProduceReferenceAssembly>true</ProduceReferenceAssembly></PropertyGroup><PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"><DebugType>portable</DebugType><DebugSymbols>true</DebugSymbols></PropertyGroup><ItemGroup><PackageReference Include="Xamarin.Forms" Version="4.8.0.1451" /><PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" /></ItemGroup><ItemGroup><ProjectReference Include="..\..\StylesLib\StylesLib.csproj" /></ItemGroup><ItemGroup><EmbeddedResource Update="RootStyles\MyInnerResourceDictionary.xaml"><Generator>MSBuild:UpdateDesignTimeXaml</Generator></EmbeddedResource><EmbeddedResource Update="MyStyles\MyOuterResourceDictionary.xaml"><Generator>MSBuild:UpdateDesignTimeXaml</Generator></EmbeddedResource></ItemGroup></Project>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。