0
在UWP,我們可以很容易地改變根據窗口大小例如按鈕的特性,使用visualstate.setters現在UWP的VisualState - 修改整個類(按鈕爲例)
<VisualState x:Name="VisualStateNarrow" >
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowHeight="{StaticResource NarrowMinHeight}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="btnTest.Height" Value="100"/>
<Setter Target="btnTest.Width" Value="100"/>
....
</VisualState.Setters>
</VisualState>
....
讓我們說我有大量的按鈕。而不是手動輸入每個條目,btnA.Height ..,BtnB.Height ...等等,有沒有辦法在custom.xaml中輸入它們?
我嘗試類似:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Template10.Controls">
<x:Double x:Key="CustomHeightN">100</x:Double>
<x:Double x:Key="CustomWidthN">100</x:Double>
<ResourceDictionary.ThemeDictionaries
<ResourceDictionary x:Key="VisualStateNarrow" >
<Style TargetType="Button">
<Setter Property="Height" Value="{ThemeResource CustomHeightN}" />
<Setter Property="Width" Value="{ThemeResource CustomWidthN}" />
</Style>
</ResourceDictionary>
....
不過,當然,這是行不通的。任何人都可以通過一個機會來提出建議
非常感謝您的回答,作品完美。 :) –