本文整理汇总了C#中System.Windows.Style.Merge方法的典型用法代码示例。如果您正苦于以下问题:C# Style.Merge方法的具体用法?C# Style.Merge怎么用?C# Style.Merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Style
的用法示例。
在下文中一共展示了Style.Merge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProvideValue
public override object ProvideValue(IServiceProvider serviceProvider)
{
Style result = new Style();
foreach (var styleKey in m_stylesKeys)
{
Style style = (Style)new StaticResourceExtension(styleKey).ProvideValue(serviceProvider);
if (style == null) new ArgumentException(styleKey + " not found");
result.Merge(style);
}
return result;
}
示例2: ProvideValue
/// <summary>
/// Returns a style that merges all styles with the keys specified in the constructor.
/// </summary>
/// <param name="serviceProvider">The service provider for this markup extension.</param>
/// <returns>A style that merges all styles with the keys specified in the constructor.</returns>
public override object ProvideValue(IServiceProvider serviceProvider)
{
Style resultStyle = new Style();
foreach(string currentResourceKey in resourceKeys) {
object key = currentResourceKey;
if(currentResourceKey == ".") {
IProvideValueTarget service = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget));
key = service.TargetObject.GetType();
}
Style currentStyle = new StaticResourceExtension(key).ProvideValue(serviceProvider) as Style;
if(currentStyle == null)
throw new InvalidOperationException("Could not find style with resource key " + currentResourceKey + ".");
resultStyle.Merge(currentStyle);
}
return resultStyle;
}