WPF 基础(二)程序集应用:一个项目引用另一项目的DLL,这个DLL包含了ImageButton.cs,ImageButton.cs再引用图片资源

本文探讨了在WPF应用程序中,如何从一个项目(如KeenRay.BBB)引用并正确定位到另一个项目(如KeenRay)中的图片资源。通过详细解释ImageButton组件如何关联主项目中的图片资源,以及在不同项目间正确引用DLL的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

工程目录:

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目录下

如何没有这一步,以上操作都是空谈。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我爱AI

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值