admin管理员组文章数量:1392002
Style for BoxView:
<Style x:Key="LabeledFieldPlaceholderBoxViewStyle"
TargetType="BoxView">
<Setter Property="HeightRequest"
Value="23"/>
<Setter Property="Margin"
Value="0, 0, 0, 0"/>
<Setter Property="Color"
Value="Transparent"/>
<Setter Property="BackgroundColor"
Value="Transparent"/>
</Style>
CommonTempaltes.xaml
<ResourceDictionary
x:Class="Same.Mobile.UI.Core.Resources.CommonTemplates"
xmlns=";
xmlns:x=";
xmlns:baseclasses="clr-namespace:Same.Mobile.UI.Core.BaseClasses"
xmlns:behaviors="clr-namespace:Same.Mobile.UI.Core.Behaviors"
xmlns:const="clr-namespace:Same.Mobile.UI.Core;assembly=Same.Mobile.UI.Core"
xmlns:ctrls="clr-namespace:Same.Mobile.UI.Core.Controls;assembly=Same.Mobile.UI.Core"
xmlns:helper="clr-namespace:Same.Mobile.UI.Core.Helpers;assembly=Same.Mobile.UI.Core"
xmlns:model="clr-namespace:Same.Mobile.UI.Core.Abstractions.Models;assembly=Same.Mobile.UI.Core.Abstractions"
xmlns:toolkit=";>
<!-- ControlTemplate -->
<ControlTemplate x:Key="EntryFieldTemplate">
<VerticalStackLayout
x:DataType="ctrls:EntryField"
ClassId="_entryFieldLayout"
HorizontalOptions="{TemplateBinding Path=HorizontalOptions}"
VerticalOptions="{TemplateBinding Path=VerticalOptions}"
WidthRequest="{TemplateBinding Path=WidthRequest}">
<!-- Label - visibility is determined by converter (see class) -->
<Label
x:Name="_entryFieldLabel"
AutomationId="LabelText"
ClassId="_entryFieldLabel"
Style="{TemplateBinding Path=LabelTextStyle}"
Text="{TemplateBinding Path=LabelText}"/>
<BoxView
AutomationId="BoxViewPlaceholder"
IsVisible="{Binding Path=IsVisible, Source={Reference Name=_entryFieldLabel}, Converter={StaticResource InvertedBoolConverter}}"
Style="{DynamicResource Key=LabeledFieldPlaceholderBoxViewStyle}">
<BoxView.Triggers>
<DataTrigger TargetType="BoxView"
Binding="{Binding Path=IsVisible, Source={Reference Name=_entryFieldLabel}, Converter={StaticResource Key=InvertedBoolConverter}}"
Value="True">
<Setter Property="HeightRequest"
Value="23"/>
</DataTrigger>
<DataTrigger TargetType="BoxView"
Binding="{Binding Path=IsVisible, Source={Reference Name=_entryFieldLabel}, Converter={StaticResource Key=InvertedBoolConverter}}"
Value="False">
<Setter Property="HeightRequest"
Value="1"/>
</DataTrigger>
</BoxView.Triggers>
</BoxView>
<Entry
AutomationId="FieldText"
ClassId="_entryFieldEntry"
HeightRequest="{TemplateBinding Path=FieldHeightRequest}"
IsEnabled="{TemplateBinding Path=IsEnabled}"
IsPassword="{TemplateBinding Path=IsPassword}"
Keyboard="{TemplateBinding Path=Keyboard}"
Placeholder="{TemplateBinding Path=Placeholder}"
Style="{TemplateBinding Path=EntryStyle}"
Text="{TemplateBinding Path=Text,
Mode=TwoWay}"
WidthRequest="{TemplateBinding Path=FieldWidthRequest}"/>
<Label
AutomationId="ValidationResult"
IsVisible="{TemplateBinding Path=ValidationResult.IsValid,
Converter={StaticResource Key=InvertedBoolConverter}}"
Style="{DynamicResource Key=SmallValidationErrorLabelStyle}"
Text="{TemplateBinding Path=ValidationResult,
Converter={StaticResource Key=ValidationErrorsLabelConverter}}"/>
</VerticalStackLayout>
</ControlTemplate>
<Style TargetType="ctrls:EntryField">
<Setter Property="ControlTemplate"
Value="{StaticResource Key=EntryFieldTemplate}"/>
</Style>
</ResourceDictionary>
Using like this in cosuming app.
<Application
x:Class="CoreTestApp.App"
xmlns=";
xmlns:x=";
xmlns:commonResources="clr-namespace:Same.Mobile.UI.Core.Resources;assembly=Same.Mobile.UI.Core"
xmlns:local="clr-namespace:CoreTestApp">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
<commonResources:CommonStyles />
<commonResources:CommonTemplates />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
This template is working fine before moving to compiled bindings. To use compiled bindings I have enabled this from csproject file:
<MauiEnableXamlCBindingWithSourceCompilation>true</MauiEnableXamlCBindingWithSourceCompilation>
After enabling this I have noticed that BoxView control's height is not changing dynamically, so I have added the trigger to handle its height dynamically. Now if I add this project locally or use .dll file of it in consuming project than it did work fine. But when this changes got publised and I got updated version of nuget package (for this) it's not working in consuming project.
To make sure this work I have added this code in .csproject file already but still it did not works when it gets published and I use it as nuget.
<ItemGroup>
<None Include="Resources\CommonStyles.xaml" Pack="True" PackagePath="buildTransitive\Resources\" />
<None Include="Resources\CommonTemplates.xaml" Pack="True" PackagePath="buildTransitive\Resources\" />
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Resources\CommonStyles.xaml" Pack="True" PackagePath="buildTransitive\Resources\" />
<MauiXaml Update="Resources\CommonTemplates.xaml" Pack="True" PackagePath="buildTransitive\Resources\" />
</ItemGroup>
This work fine if I add this project reference locally in consuming project or use debug .dll file.
How to handle this?
本文标签: Resource Dictionary Not Loading After Enabling Compiled Bindings in Net MAUIStack Overflow
版权声明:本文标题:Resource Dictionary Not Loading After Enabling Compiled Bindings in .Net MAUI - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744760493a2623727.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论