मेरे पास एक थीम है जो संसाधन शब्दकोश में सभी बटनों पर लागू होती है। अब मैं शब्दकोश से स्टाइल बदलावों को विरासत में रखते हुए बटन पर एक ट्रिगर जोड़ना चाहता हूं। मैंने निम्नलिखित कोड का प्रयास किया:संसाधन शब्दकोश में किसी अन्य शैली पर एक शैली का आधार
लेकिन यह कहता है कि नियंत्रण नहीं मिला। मैं इसे कैसे ठीक कर सकता हूं?
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Theme.xaml"/>
</ResourceDictionary.MergedDictionaries>
<conv:ErrorContentConverter x:Key="ErrorContentConverter" />
<Style x:Key="ValidTrigger"
TargetType="Control" BasedOn="{StaticResource {x:Type Control}}" >
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsValid}" Value="False">
<Setter Property="IsEnabled" Value="false" />
</DataTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</UserControl.Resources>
और आधार टेम्पलेट:
<Style TargetType="{x:Type Button}" BasedOn="{x:Null}">
<Setter Property="FocusVisualStyle"
Value="{DynamicResource NuclearButtonFocusVisual}" />
<Setter Property="Foreground" Value="#FF042271" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Padding" Value="3" />
<Setter Property="Template" Value="{DynamicResource ButtonTemplate}" />
</Style>
क्या मैं इसे नाम निर्दिष्ट किए बिना कर सकता हूं? शब्दकोश में नियंत्रण के लिए केवल एक शैली है। – Marcom
क्या आपका मतलब है कि, आधार शैली की कुंजी असाइन करने के बजाय, आप विस्तारित शैली को यह पता लगाने के लिए चाहते हैं कि किस शैली को इसके लक्ष्य प्रकार के आधार पर विस्तारित किया जाए? मुझे नहीं पता। –
आप मूल शैली को x: कुंजी = "FooStyle" देने में क्यों संकोच करते हैं? –