小编Swo*_*per的帖子

如何在xaml中引用.resx文件中的图标?

我正在使用.resx文件进行资源管理的C#WPF应用程序.现在,我正在尝试向项目添加图标(.ico),但我遇到了一些问题.

<Image Name="imgMin" Grid.Column="0"
       Stretch="UniformToFill"
       Cursor="Hand" 
       MouseDown="imgMin_MouseDown">
    <Image.Style>
        <Style TargetType="{x:Type Image}">
            <Setter Property="Source" Value="\Images\minimize_glow.ico"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Source" Value="\Images\minimize_glow.ico"/>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Image.Style>
</Image>
Run Code Online (Sandbox Code Playgroud)

这工作正常,但是当我将图标移动到AppResources.resx时,我遇到了在xaml代码中引用它的问题.我应该使用什么而不是上面的Setter Property = ...行?这个:

<Setter Property="Source" Value="{x:Static res:AppResources.minimize}"/>
Run Code Online (Sandbox Code Playgroud)

不起作用,我想我可能需要使用与"Source"不同的Property,因为Value不是指向图标的字符串,而是现在的图标本身.我无法弄清楚使用哪一个 - 请帮助一下?

.net c# data-binding wpf icons

10
推荐指数
1
解决办法
4416
查看次数

制作图像点击,但仍然响应鼠标悬停?

标题基本概括了所有内容.有没有办法让XAML代码中的图像可见,而不是可点击(我试图使其后面的元素接收到点击)并同时响应鼠标悬停事件?该IsHitTestVisible属性禁用鼠标悬停.这是一个供参考的代码片段(它实际上使用了多个额外的MultiDataTriggers,但这里不相关).目前鼠标悬停工作,但点击它没有(添加IsHitTestVisible="True"使其相反)

<Image Name="AutoUpdateStatus"
       Stretch="UniformToFill"
       Grid.Column="2" Grid.Row="0"
       Height="32" Width="32"
       HorizontalAlignment="Center"
       Margin="68,2,61,2"
       VerticalAlignment="Center">
    <Image.Style>
        <Style>
            <Setter Property="Image.Source">
                <Setter.Value>
                    <Binding Source="{x:Static res:AppResources.ok}">
                        <Binding.Converter>
                            <Helpers:IconToImageSourceConverter />
                        </Binding.Converter>
                    </Binding>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" Value="True" />
                        <Condition Binding="{Binding Path=AutoUpdateStatusIcon}" Value="ok" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Image.Source">
                        <Setter.Value>
                            <Binding Source="{x:Static res:AppResources.ok_glow}">
                                <Binding.Converter>
                                    <Helpers:IconToImageSourceConverter />
                                </Binding.Converter>
                            </Binding>
                        </Setter.Value>
                     </Setter>
                 </MultiDataTrigger>
             </Style.Triggers>
         </Style>
     </Image.Style>
 </Image>
Run Code Online (Sandbox Code Playgroud)

wpf xaml image mouseover

8
推荐指数
1
解决办法
1317
查看次数

在WPF中的鼠标悬停事件?

我正在尝试在WPF MVVM应用程序中实现工具提示系统.工具提示应该出现在某个标签中,该标签是MainWindow的一部分(不会悬停在鼠标指针上)并且应该在鼠标悬停时发生(理想情况下具有可配置的延迟,但这并不重要),调用方法在适当的ViewModel中.然后,ViewModel将处理与Model层的联系,该层将解析要显示的工具提示等.

我的问题是如何从视图到ViewModel获取鼠标悬停事件,以及触发事件的对象的身份(所以我可以为它解决正确的工具提示).假设我<Label Name="MyLabel" Content="This is a label" />在我的SettingsView.xaml中有一个,如何让它GetTooltip(string id)在设置视图中使用MyLabel作为参数调用方法(或以其他方式可访问)?我<Trigger>能以某种方式使用常规吗?

wpf events mouseover onmouseover mvvm

7
推荐指数
1
解决办法
5125
查看次数

Perl:解码"乱码"unicode字符串

我正在研究一个从一个软件调用的CGI脚本(我无法改变).软件提交的变量给我带来了问题,因为如果它们包含非ascii字符,它们看起来像这样:

ÿFFFFDEetta er texti meÿFFFFF0 ÿFFFFEDslenskum stÿFFFFF6fum

代替

Þetta er texti með íslenskum stöfum.

我已经尝试搞乱这个Encode::decode功能,但没有任何结果 - 我所要做的就是改变ÿ代表的方式.

所以,是的,我有点难过.如何将所有ÿFFFFDEs 更改为Þs等等,而不是单独替换每个非ascii字符(这不是一个解决方案,因为这需要适用于我甚至不会说的语言)?

unicode perl

4
推荐指数
1
解决办法
727
查看次数

标签 统计

wpf ×3

mouseover ×2

.net ×1

c# ×1

data-binding ×1

events ×1

icons ×1

image ×1

mvvm ×1

onmouseover ×1

perl ×1

unicode ×1

xaml ×1