wpf窗口启动图像
理想情况下,我希望将窗口的资源保留在资源字典中,但在声明 window.resources 部分之前,我一直在寻找让它们知道的最佳方法。所以我最终做了类似下面代码的事情。
有没有办法静态引用背景图像画笔?我怎样才能做得更好?
干杯,
贝里尔
<Window x:Class="Smack.ConstructionAdmin.Presentation.Wpf.Views.ProjectPicker.ProjectPickerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
...
Background="{DynamicResource waveBrush}"
Icon="pack://application:,,,/MyAssembly;component/Images/Project_32.png"
...
>
<Window.Resources>
<ImageBrush
x:Key="waveBrush" Stretch="Fill" ImageSource="pack://application:,,,/MyAssembly;component\Images\Wave.jpg"
/>
</Window.Resources>
I would ideally like to keep the resources for a window in a resource dictionary, but am getting stuck as to the best way to make them known before you declare the window.resources section. So I wind up doing something like the code below.
Is there someway to reference the background image brush statically? How can I do better?
Cheers,
Berryl
<Window x:Class="Smack.ConstructionAdmin.Presentation.Wpf.Views.ProjectPicker.ProjectPickerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
...
Background="{DynamicResource waveBrush}"
Icon="pack://application:,,,/MyAssembly;component/Images/Project_32.png"
...
>
<Window.Resources>
<ImageBrush
x:Key="waveBrush" Stretch="Fill" ImageSource="pack://application:,,,/MyAssembly;component\Images\Wave.jpg"
/>
</Window.Resources>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的项目中的 Application.xaml 文件中
Application .资源
部分。您还可以使用独立的资源文件并将其包含在 Windows xaml 文件或 Application.xaml 文件中。
或者
In your projects Application.xaml file in the
Application.Resources
Section.Your could also use a standalone Resource File and include it in your windows xaml file or the Application.xaml file.
Or