C# 如何将Button.Style设置为WPF中代码隐藏的x:静态资源?
我需要使用C#调用代码隐藏中按钮样式的静态资源 这是我在XAML中的按钮:C# 如何将Button.Style设置为WPF中代码隐藏的x:静态资源?,c#,asp.net,.net,wpf,C#,Asp.net,.net,Wpf,我需要使用C#调用代码隐藏中按钮样式的静态资源 这是我在XAML中的按钮: <Button Height="48" HorizontalAlignment="Left" Margin="229,0,0,0" Name="btnlogin" VerticalAlignment="Top" Width="90" Grid.Row="6" BorderThickness="0" MouseEnter="btnlogin_MouseEnter" MouseLea
<Button Height="48" HorizontalAlignment="Left" Margin="229,0,0,0" Name="btnlogin"
VerticalAlignment="Top" Width="90" Grid.Row="6" BorderThickness="0"
MouseEnter="btnlogin_MouseEnter" MouseLeave="btnlogin_MouseLeave"
BorderBrush="Transparent"
Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
<Button.Background>
<ImageBrush ImageSource="/BaccaratDealerInterfaceWPF;component/Images/Login_Button_Normal.png" />
</Button.Background>
</Button>
试一试
以下是此样式的详细信息以及如何在这两种方式中访问它:
- 代码隐藏
ToolBar.ButtonStyleKey
- XAML
- 代码隐藏
ToolBar.ButtonStyleKey
- XAML
- 代码隐藏
ToolBar.ButtonStyleKey
- XAML
- 代码隐藏
ToolBar.ButtonStyleKey
- XAML
Style style = this.FindResource("{x:Static ToolBar.ButtonStyleKey}") as Style;
btnlogin.Style = style;
this.FindResource(ToolBar.ButtonStyleKey);