工程目录:
KeenRay项目(主程序) ——WPF可执行程序
KeenRay.Controls项目 ——类库
KeenRay.BBB项目 ——类库
一、我的目的:
在一个项目引用另一项目的DLL,这个DLL包含了ImageButton.cs,ImageButton.cs再引用图片资源(比如DefaultImage="{StaticResource History.Sendpacs.Enable.Icon}")。实际上,该问题可以描述为: BBB项目如何找到图片?
1、KeenRay.BBB项目:
<UserControl x:Class="KeenRay.BBB.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:KeenRay.BBB"
xmlns:controls="clr-namespace:KeenRay.Controls;assembly=KeenRay.Controls"
mc:Ignorable="d"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<!--<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="118,164,0,0" VerticalAlignment="Top" Width="75"/>-->
<TextBox Canvas.Top="25" Canvas.Right="0" Text="{Binding PatientID,Mode=TwoWay}" Style="{DynamicResource TextBoxStyle163x42}"/>
<controls:ImageButton x:Name="btn_Sendpacs" Canvas.Top="18" Canvas.Right="456" Width="122" Height="52" ToolTip="{DynamicResource History.Search.Sendpacs.Tooltip}" DefaultImage="{StaticResource History.Sendpacs.Enable.Icon}" PressedImage="{StaticResource History.Sendpacs.Touches.Icon}" Margin="97,48,81,200"/>
</Grid>
</UserControl>
2、KeenRay.BBB项目如何找到ImageButton?
引用程序集即可。
3、ImageButton如何找到 DefaultImage="{StaticResource History.Sendpacs.Enable.Icon}" ?
History.Sendpacs.Enable.Icon是保存在主项目中:
那么,ImageButton如何关联该图片资源呢?
KeenRay项目(主程序)又引用了KeenRay.Controls项目,这时候,ImageButton就能关联主程序的图片资源。
4、如何你把该引用删除,就不能正确使用了。
二、KeenRay.BBB项目生成的DLL一定要放在公共Bin目录下
如何没有这一步,以上操作都是空谈。