wpf window start up images
I would ideally like to keep the resources for a win开发者_开发技巧dow 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>
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.
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Background="{DynamicResource MyBackColor}">
<Window.Resources>
<ResourceDictionary Source="Resources\MyResourceDictionary.xaml" />
</Window.Resources>
<Grid>
</Grid>
</Window>
Or
<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary Source="Resources\MyResourceDictionary.xaml" />
</Application.Resources>
精彩评论