本文整理汇总了C#中Windows.UI.Xaml.Style类的典型用法代码示例。如果您正苦于以下问题:C# Style类的具体用法?C# Style怎么用?C# Style使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Style类属于Windows.UI.Xaml命名空间,在下文中一共展示了Style类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetStyle
Style GetStyle(object nativeKey)
{
var style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources[nativeKey];
var formsStyle = new Style(typeof(Label));
foreach (SetterBase b in style.Setters)
{
var setter = b as Windows.UI.Xaml.Setter;
if (setter == null)
continue;
// TODO: Need to implement a stealth pass-through for things we don't support
try
{
if (setter.Property == TextBlock.FontSizeProperty)
formsStyle.Setters.Add(Label.FontSizeProperty, setter.Value);
else if (setter.Property == TextBlock.FontFamilyProperty)
formsStyle.Setters.Add(Label.FontFamilyProperty, setter.Value);
else if (setter.Property == TextBlock.FontWeightProperty)
formsStyle.Setters.Add(Label.FontAttributesProperty, ToAttributes(Convert.ToUInt16(setter.Value)));
else if (setter.Property == TextBlock.TextWrappingProperty)
formsStyle.Setters.Add(Label.LineBreakModeProperty, ToLineBreakMode((TextWrapping)setter.Value));
}
catch (NotImplementedException)
{
// see https://bugzilla.xamarin.com/show_bug.cgi?id=33135
// WinRT implementation of Windows.UI.Xaml.Setter.get_Value is not implemented.
}
}
return formsStyle;
}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:33,代码来源:WindowsResourcesProvider.cs
示例2: IsCheckedChanged
private void IsCheckedChanged()
{
if (IsChecked)
{
if (CheckedStyle != null)
{
_style = Style;
Style = CheckedStyle;
}
if (CheckedAutomationName != null)
{
_automationName = AutomationName;
AutomationName = CheckedAutomationName;
}
}
else
{
if (CheckedStyle != null)
{
Style = _style;
}
if (CheckedAutomationName != null)
{
AutomationName = _automationName;
}
}
}
开发者ID:sdao,项目名称:TuneOut,代码行数:29,代码来源:AppBarToggleButton.cs
示例3: ColorButtons
/// <summary>
/// This method will change the style of each AppBarButton to use a green foreground color
/// </summary>
/// <param name="panel"></param>
private void ColorButtons(StackPanel panel)
{
int count = 0;
foreach (var item in panel.Children)
{
// For AppBarButton, change the style
if (item.GetType() == typeof(AppBarButton))
{
if (count == 0)
{
originalButtonStyle = ((AppBarButton)item).Style;
}
((AppBarButton)item).Style = rootPage.Resources["GreenAppBarButtonStyle"] as Style;
count++;
}
else
{
// For AppBarSeparator(s), just change the foreground color
if (item.GetType() == typeof(AppBarSeparator))
{
originalSeparatorBrush = ((AppBarSeparator)item).Foreground;
((AppBarSeparator)item).Foreground = new SolidColorBrush(Color.FromArgb(255, 90, 200, 90));
}
}
}
}
开发者ID:ckc,项目名称:WinApp,代码行数:30,代码来源:Scenario2_CustomizeColor.xaml.cs
示例4: Convert
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value == null) return null;
var resourceKey = value.ToString();
var resource = Application.Current.Resources[resourceKey] as Style;
if (resource != null)
{
var style = new Style();
style.BasedOn = resource.BasedOn;
style.TargetType = resource.TargetType;
foreach (var setter in resource.Setters)
{
var s = setter as Setter;
if (s != null)
{
var g = s.Value as PathGeometry;
if (g != null)
{
style.Setters.Add(new Setter(s.Property, CloneDeep(g)));
}
else
{
style.Setters.Add(new Setter(s.Property, s.Value));
}
}
}
return style;
}
return null;
}
开发者ID:fernandoescolar,项目名称:myweather,代码行数:34,代码来源:StyleStaticResourceConverter.cs
示例5: SelectStyleCore
protected override Style SelectStyleCore(object item,
DependencyObject container)
{
Style st = new Style();
st.TargetType = typeof(ListViewItem);
Setter backGroundSetter = new Setter();
backGroundSetter.Property = ListViewItem.BackgroundProperty;
ListView listView =
ItemsControl.ItemsControlFromItemContainer(container)
as ListView;
int index =
listView.IndexFromContainer(container);
if (index % 2 == 0)
{
backGroundSetter.Value = (Color)Application.Current.Resources["SystemBackgroundAltHighColor"];
}
else
{
backGroundSetter.Value = (Color)Application.Current.Resources["SystemAltHighColor"];
}
st.Setters.Add(backGroundSetter);
Setter paddingSetter = new Setter();
paddingSetter.Property = ListViewItem.PaddingProperty;
paddingSetter.Value = 0;
st.Setters.Add(paddingSetter);
Setter alignSetter = new Setter();
alignSetter.Property = ListViewItem.HorizontalContentAlignmentProperty;
alignSetter.Value = "Stretch";
st.Setters.Add(alignSetter);
return st;
}
开发者ID:aurora-lzzp,项目名称:com.aurora.aumusic,代码行数:31,代码来源:ListViewItemStyleSelector.cs
示例6: PrepareContainerForItemOverride
internal static void PrepareContainerForItemOverride(DependencyObject element, Style parentItemContainerStyle)
{
var control = element as Control;
if (parentItemContainerStyle != null && control != null && control.Style == null)
{
control.SetValue(FrameworkElement.StyleProperty, parentItemContainerStyle);
}
}
开发者ID:JanJoris,项目名称:Expander,代码行数:8,代码来源:ItemsControlHelper.cs
示例7: PreparePrepareHeaderedItemsControlContainerForItemOverride
internal static void PreparePrepareHeaderedItemsControlContainerForItemOverride(DependencyObject element, object item, ItemsControl parent, Style parentItemContainerStyle)
{
var headeredItemsControl = element as HeaderedItemsControl;
if (headeredItemsControl != null)
{
PreparePrepareHeaderedItemsControlContainer(headeredItemsControl, item, parent, parentItemContainerStyle);
}
}
开发者ID:JanJoris,项目名称:Expander,代码行数:8,代码来源:HeaderedItemsControl.cs
示例8: CreateGrid
public static Grid CreateGrid(Style s, Grid g)
{
Grid newG = new Grid();
newG.Style = s;
g.Children.Add(newG);
return newG;
}
开发者ID:BlowingPolarBears,项目名称:MagicPolarBear,代码行数:9,代码来源:CreateXAMLObj.cs
示例9: AdaptiveGridView
public AdaptiveGridView()
{
if (ItemContainerStyle == null)
ItemContainerStyle = new Style(typeof(GridViewItem));
ItemContainerStyle.Setters.Add(new Setter(HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch));
Loaded += AdaptiveGridView_Loaded;
}
开发者ID:Flogex,项目名称:Vertretungsplan,代码行数:9,代码来源:AdaptiveGridView.cs
示例10: SharedBrushWithStylePage
public SharedBrushWithStylePage() {
// Taken from Petzold book but never tested. Needs another setter for LinearGradientBrush.
Style style = new Style(typeof(TextBlock));
style.Setters.Add(new Setter { Property = TextBlock.FontSizeProperty, Value = 96 });
style.Setters.Add(new Setter { Property = TextBlock.FontFamilyProperty, Value = "Times New Roman" });
this.Resources.Add("rainbowStyle", style);
this.InitializeComponent();
}
开发者ID:ronlemire2,项目名称:UWP-Testers,代码行数:9,代码来源:SharedBrushWithStylePage.xaml.cs
示例11: CreateTextBlock
public static TextBlock CreateTextBlock(string txt, Style s, Grid g)
{
TextBlock tB = new TextBlock();
tB.Text = txt;
tB.Style = s;
g.Children.Add(tB);
return tB;
}
开发者ID:BlowingPolarBears,项目名称:MagicPolarBear,代码行数:10,代码来源:CreateXAMLObj.cs
示例12: CreateTextBox
public static TextBox CreateTextBox(string name,Style s, Grid g)
{
TextBox tB = new TextBox();
tB.Name = name;
tB.Style = s;
g.Children.Add(tB);
return tB;
}
开发者ID:BlowingPolarBears,项目名称:MagicPolarBear,代码行数:11,代码来源:CreateXAMLObj.cs
示例13: SelectStyleCore
protected override Style SelectStyleCore(object item, DependencyObject container)
{
SolidColorBrush highlight;
if (_index % 2 == 0)
highlight = new SolidColorBrush(Colors.White);
else
highlight = new SolidColorBrush(Colors.CornflowerBlue);
_index++;
Style style = new Style(container.GetType());
style.Setters.Add(new Setter(Control.BackgroundProperty, highlight));
return style;
}
开发者ID:stephgou,项目名称:Thot,代码行数:13,代码来源:AlternateRowStyleSelector.cs
示例14: CreateButton
public static Button CreateButton(string name, Style s, string content, RoutedEventHandler button_Click, Grid g)
{
Button button = new Button();
button.Name = name + "_Button";
button.Style = s;
button.Content = content;
button.Click += button_Click;
g.Children.Add(button);
return button;
}
开发者ID:BlowingPolarBears,项目名称:MagicPolarBear,代码行数:13,代码来源:CreateXAMLObj.cs
示例15: GetButton
public static Button GetButton(string content, Style style, RoutedEventHandler callback, object tag = null)
{
Button btn = new Button();
btn.Content = content;
btn.Margin = new Thickness(0, 0, 0, 0);
btn.Tag = tag;
btn.Loaded += btn_Loaded;
if (style != null)
btn.Style = style;
if (callback != null)
btn.Click += callback;
return btn;
}
开发者ID:RedSafi-UX,项目名称:SugarUIEnhancedControls,代码行数:13,代码来源:DateTimeHelper.cs
示例16: MainPage
public MainPage()
{
this.InitializeComponent();
Style style = new Style(typeof(Button));
style.Setters.Add(new Setter(Button.HeightProperty, 70));
style.Setters.Add(new Setter(Button.WidthProperty, 140));
style.Setters.Add(new Setter(Button.BackgroundProperty, Colors.Orange));
btn.Style = style;
btn2.Style = (Style)Application.Current.Resources["btn_140x70"];
}
开发者ID:simple0812,项目名称:uwp,代码行数:14,代码来源:MainPage.xaml.cs
示例17: SelectStyleCore
protected override Style SelectStyleCore(object item, DependencyObject container)
{
var style = new Style {TargetType = typeof (ListViewItem)};
var backgroudSetter = new Setter {Property = Windows.UI.Xaml.Controls.Control.BackgroundProperty};
var listview = ItemsControl.ItemsControlFromItemContainer(container) as ListView;
if (listview != null)
{
var index = listview.IndexFromContainer(container);
backgroudSetter.Value = index%2==0 ? EvenColorBrush : OddColorBrush ;
}
style.Setters.Add(backgroudSetter);
return style;
}
开发者ID:startewho,项目名称:SLWeek,代码行数:15,代码来源:ListViewItemStyleSelector.cs
示例18: IsCheckedChanged
private void IsCheckedChanged()
{
if (IsChecked)
{
_content = Content;
_style = Style;
if (CheckedStyle == null) Content = CheckedContent;
else Style = CheckedStyle;
}
else
{
if (CheckedStyle == null) Content = _content;
else Style = _style;
}
}
开发者ID:hyptechdev,项目名称:SubSonic8,代码行数:16,代码来源:AppBarToggleButton.cs
示例19: V_PropertyChanged
private void V_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName.Equals("Melodies"))
{
PivotItem pi = new PivotItem();
pi.Header = "songs";
StrechItemsListView lv = new StrechItemsListView();
Style s = new Style(typeof(ListViewItem));
s.Setters.Add(new Setter(ListViewItem.HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch));
lv.ItemContainerStyle = s;
lv.ItemsSource = ((WeaponDetailsViewModel)DataContext).Melodies;
lv.ItemTemplate = Resources["SongTemplate"] as DataTemplate;
pi.Content = lv;
pivot.Items.Insert(1, pi);
}
}
开发者ID:JosephMichels,项目名称:WP-MH4UDatabase,代码行数:17,代码来源:WeaponDetailsPage.xaml.cs
示例20: SelectStyleCore
protected override Style SelectStyleCore(object item, DependencyObject container)
{
Style style = new Style(typeof(ListViewItem));
ChartSectionItem csi = item as ChartSectionItem;
if (csi.highlight.Contains("red") || csi.exphighlight.Contains("red"))
{
style.Setters.Add(new Setter(ListViewItem.ForegroundProperty, new SolidColorBrush(Colors.Red)));
}
else
{
style.Setters.Add(new Setter(ListViewItem.ForegroundProperty, new SolidColorBrush(Colors.Black)));
}
return style;
}
开发者ID:bdecori,项目名称:win8,代码行数:18,代码来源:Utility.cs
注:本文中的Windows.UI.Xaml.Style类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论