none
.net core 3.0 WPF 图片控件在设计器里面正常显示 但是编译后不显示图片 RRS feed

全部回复

  • .net core 3.0 WPF 图片控件在设计器里面正常显示 但是编译后不显示图片

    Hi  suncaomei,

    你应该是使用了相对路径,并且图片资源Build Action 为NULL,编译后运行不显示图片。

    比如:

      <Image x:Name="image" HorizontalAlignment="Left" Height="127" Margin="61,158,0,0" VerticalAlignment="Top" Source="\images\test002.JPG" Width="179"/>
    
    你可以讲图片资源的属性Build Action 设为 Resource

    然后使用Pack URI:
    <Image x:Name="image" HorizontalAlignment="Left" Height="127" Margin="61,158,0,0" VerticalAlignment="Top" Source="pack://application:,,,/images/test002.JPG " Width="179"/>
    
    参考:

    WPF 中的 Pack URI


    Best regards

    Yong Lu



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2019年11月25日 5:14
    版主