小编Fed*_*dor的帖子

使用故事板在动画期间更改图像

我正在寻找一种在故事板中更改图像的方法,或者更具体地说,更改Source图像的属性以指向新的图像资源.似乎有一个StringAnimationUsingKeyFrames和一个DiscreteStringKeyFrame但是这不起作用(据我所知),因为Image的Source属性是类型的ImageSource

我目前的故事板看起来像这样

<Storyboard x:Key="TransitionImage">
    <DoubleAnimationUsingKeyFrames
        BeginTime="00:00:00" 
        Storyboard.TargetName="image" 
        Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
        <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="0.2"/>
        <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="1"/>
    </DoubleAnimationUsingKeyFrames>
    <StringAnimationUsingKeyFrames
        BeginTime="00:00:00"
        Storyboard.TargetName="image"
        Storyboard.TargetProperty="(Image.Source)">
        <!-- This does not work -->
        <DiscreteStringKeyFrame KeyTime="00:00:00.7000000" Value="check_24.png"/>
    </StringAnimationUsingKeyFrames>
    <DoubleAnimationUsingKeyFrames 
        BeginTime="00:00:00" 
        Storyboard.TargetName="image"
        Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
        <SplineDoubleKeyFrame KeyTime="00:00:00.7000000" Value="0.2"/>
        <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="1"/>
    </DoubleAnimationUsingKeyFrames>
</Storyboard>
Run Code Online (Sandbox Code Playgroud)

和图像

<Image x:Name="image" 
       Source="delete_24.png"
       Width="32" Height="32"
       Margin="8"
       RenderTransformOrigin="0.5,0.5">
    <Image.RenderTransform>
        <TransformGroup>
            <ScaleTransform/>
            <SkewTransform/>
            <RotateTransform/>
            <TranslateTransform/>
        </TransformGroup>
    </Image.RenderTransform>
</Image>
Run Code Online (Sandbox Code Playgroud)

我可以Source将图像更改为故事板的一部分,还是我运气不好?

wpf xaml image storyboard

11
推荐指数
1
解决办法
1万
查看次数

使用Watin更改IE实例的代理设置

我知道我可以更改计算机全局代理设置Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings,以影响使用Watin创建的IE实例.

但有没有办法拦截IE浏览器发出的请求并通过代理运行它们?我的目标是运行IE的多个实例,每个实例都有自己的代理,这对于我上面的当前解决方案是不可能的.

c# asp.net watin unit-testing

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

我可以添加/减去绑定到元素属性的值吗?

XAML是否允许修改绑定值?
喜欢Width="{Binding Elementname="lstMine", Path=Width}" -100?这样我就可以拥有相对价值.

wpf xaml

9
推荐指数
1
解决办法
4874
查看次数

点击"输入"不会在IE8中发布表单

我正在使用PHP在需要时传递登录表单,这里是代码:

$htmlForm = '<form id="frmlogin">'.'<label>';
switch(LOGIN_METHOD)
{
    case 'both':
        $htmlForm .= $ACL_LANG['USERNAME'].'/'.$ACL_LANG['EMAIL'];
        break;
    case 'email':
        $htmlForm .= $ACL_LANG['EMAIL'];
        break;
    default:
        $htmlForm .= $ACL_LANG['USERNAME'];
        break;
}                       

$htmlForm .= ':</label>'.
             '<input type="text" name="u" id="u" class="textfield" />'.
             '<label>'.$ACL_LANG['PASSWORD'].'</label>'.
             '<input type="password" name="p" id="p" class="textfield" />'.
             '<center><input type="submit" name="btn" id="btn" class="buttonfield" value="Sign in to extranet" /></center>'.
             '</form>';

return $htmlForm;
Run Code Online (Sandbox Code Playgroud)

问题是,当用户点击进入IE8时,表单不提交,并且用户被迫点击提交按钮.

我该如何纠正这个?

html php forms submit form-submit

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

从DataTrigger在WPF TreeViewItem上设置IsExpanded

我正在尝试使用条件模板设置IsExpanded我的TreeView项目的属性,在XAML:

<DataTrigger Binding="{Binding MyStatus}" Value="Opened">
    <Setter TargetName="MyTextBlock" Property="Foreground" Value="Green"/>
    <Setter Property="TreeViewItem.IsExpanded" Value="True" />
</DataTrigger>
Run Code Online (Sandbox Code Playgroud)

当我MyStatus从C#代码设置属性时,颜色会更改(因此DataTrigger工作),但节点不会展开.

_myItems[0].MyStatus = MyStatus.Opened;
Run Code Online (Sandbox Code Playgroud)

如何设置TreeViewItem.IsExpanded属性DataTrigger

当我启动应用程序时,颜色已正确设置,但绿色节点未展开:

启动应用程序后的屏幕截图

而改变的值之后_myItems[0].MyStatus_myItems[1].MyStatus,颜色也会随之改变,但绿点仍然没有展开.

单击Button1后的屏幕截图

完整代码(XAML)

完整的代码有点长,但它是90%的样板.

<Window x:Class="WpfApplication6.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="150" Width="250">
    <DockPanel>
        <DockPanel.Resources>
            <HierarchicalDataTemplate ItemsSource="{Binding SubItems}" x:Key="MyTemplate">
                <StackPanel Orientation="Horizontal">
                    <!-- ... -->
                    <TextBlock x:Name="MyTextBlock" Foreground="Green" Text="{Binding Name}" />
                </StackPanel>

                <HierarchicalDataTemplate.Triggers>
                    <DataTrigger Binding="{Binding MyStatus}" Value="Closed">
                        <Setter TargetName="MyTextBlock" Property="Foreground" Value="Red"/>
                        <Setter Property="TreeViewItem.IsExpanded" Value="False" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding …
Run Code Online (Sandbox Code Playgroud)

c# wpf treeview xaml treeviewitem

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

在WPF中重构XAML

我的XAML很长很难维护.我想知道是否有办法做重构之类的事情?

这是一个简单的例子:

<Window x:Class="RefactorXAML.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">
    <Grid>
        <StackPanel>
            <Button>New</Button>
            <Button>Open</Button>
        </StackPanel>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

我怎样才能重构该Stackpanel部分并写出这样的内容?

<Window x:Class="RefactorXAML.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">
    <Grid>
        // Refactored Markup
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml

6
推荐指数
1
解决办法
1570
查看次数

safari不允许第二个window.print()

您好我在safari中遇到了一个奇怪的问题.我有一个按钮,当点击它打印html的内容.我的问题是,当第一次调用window.print()时,第二次点击它会显示一个弹出窗口,说明:'此网页正在尝试打印.你想打印这个网页吗?' 如果我在此对话框中单击打印,则不会发生任 任何想法为什么会发生这种情况?先感谢您!

码:

Javascript -

$scope.print = function() {
    var contents = document.getElementById("print-section").outerHTML;
    var frame1 = document.createElement('iframe');
    frame1.name = "frame3";
    frame1.style.position = "absolute";
    frame1.style.top = "-1000000px";
    document.body.appendChild(frame1);

    var frameDoc = frame1.contentWindow ? frame1.contentWindow : frame1.contentDocument.document ? frame1.contentDocument.document : frame1.contentDocument;
    frameDoc.document.open();
    frameDoc.document.write('<html><head>'); // add some libraries for the new document
    frameDoc.document.write('</head><body>');
    frameDoc.document.write(contents);
    frameDoc.document.write('</body></html>');
    frameDoc.document.close();
    setTimeout(function () {
        window.frames["frame3"].focus();
        window.frames["frame3"].print();
        document.body.removeChild(frame1);
    }, 500);

    return false;
};
Run Code Online (Sandbox Code Playgroud)

HTML的

<div id="print-section">
   <div>Section to print<>
</div>
Run Code Online (Sandbox Code Playgroud)

html javascript printing safari

6
推荐指数
2
解决办法
1865
查看次数

使用Treeview HierarchicalDataTemplate.Triggers更改文件夹图标

我对WPF很新鲜,这是我在审阅了此处发布的许多先前提出的问题后,最接近实现我的目标.XAML代码:

<TreeView x:Name="folderView" Grid.Column="0" Grid.Row="1" BorderThickness="0">
    <TreeViewItem Header="Folders" ItemsSource="{Binding SubFolders, Source={StaticResource RootFolderDataProvider}}" Margin="5"/>

    <TreeView.Resources>
        <HierarchicalDataTemplate DataType="{x:Type my:FolderView}" ItemsSource="{Binding SubFolders}">
            <StackPanel Orientation="Horizontal" Name="myPanel">
                <Image x:Name="img" Width="16" Height="16" Source="Images/FolderClosed.png" />
                <TextBlock Text="{Binding Name}" />
            </StackPanel>

            <HierarchicalDataTemplate.Triggers>
                <DataTrigger Binding="{Binding IsExpanded}" Value="True">
                    <Setter TargetName="img" Property="Source" Value="Images/FolderOpen.png"/>
                </DataTrigger>
            </HierarchicalDataTemplate.Triggers>
        </HierarchicalDataTemplate>    
    </TreeView.Resources>
</TreeView>
Run Code Online (Sandbox Code Playgroud)

这将显示除了最顶层根文件夹之外的所有子文件夹上的FolderClosed图像.该HierachicalDataTemplate触发还未能展开时开火.任何帮助,将不胜感激.

wpf treeview xaml hierarchicaldatatemplate

5
推荐指数
1
解决办法
5124
查看次数

在DataGrid单元格中突出显示文本的一部分

我想在WPF应用程序中突出显示数据网格中的字符串。
在WinForms中,有一个CellPainting事件可以帮助我们实现这一目的。我无法在WPF中找到任何内容。

我想突出显示单元格中存在的TEXT部分而不是整个单元格

任何帮助将不胜感激。

c# wpf highlighting

5
推荐指数
1
解决办法
1845
查看次数

如何在switch语句中使用&&运算符基于组合返回值?

如何&&在开关盒中使用操作器?

这就是我想要做的:

private int  retValue()
{
    string x, y;
    switch (x && y)
    {
        case "abc" && "1":
            return 10;
            break;
         case "xyz" && "2":
             return 20;
            break;
    }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是,"abc"并且"1"都是类型string,编译器给我的消息:

"operator &&不能应用于字符串"

c# switch-statement

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