小编Cam*_*ers的帖子

使用XAML完成Storyboard完成时将元素的可见性设置为折叠

我有一个故事板动画,使用Opacity属性将控件淡出视图.完成后,我想将控件的Visibility设置为Collapsed.

我也希望能够反过来......将可见性设置为可见,然后使用故事板将控件淡入视图.

我知道我可以连接事件,但我想在XAML中完成这一切.可能吗?

wpf xaml storyboard

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

visual studio 2010条件参考

我们这里有多个产品共享一些公共库.这些库是单独解决方案的一部分(因此它们可以由TFS独立构建),但问题是在开发期间,必须修改公共库,将其编译为二进制文件,将其复制到公共位置,编译产品解决方案.

为了避免这种情况,我实际上想知道它是否可能有条件引用,因此对于调试配置,我会将它们作为项目引用引用,而在发布配置中它们将是二进制引用.

c# tfs visual-studio-2010 visual-studio

26
推荐指数
1
解决办法
9854
查看次数

在VS 2010 RC扩展中查找给定ProjectItem的IVsTextView或IWpfTextView

我有ProjectItem,并希望获得与之关联的IWPFTextView(如果有).

我试图获取一个IVsTextManager,然后遍历视图,但iVsTextManager.EnumViews总是不返回任何内容.

这是我到目前为止所得到的:

var txtMgr = (IVsTextManager)Package.GetGlobalService(typeof(SVsTextManager));

if (txtMgr != null)
{
    IVsEnumTextViews iVsEnumTextViews;
    IVsTextView[] views = null;

    // Passing null will return all available views, at least according to the documentation
    // unfortunately, this returns a 0x80070057 error (invalid parameter)
    var errorValue = txtMgr.EnumViews(null, out iVsEnumTextViews);

    if (errorValue == VSConstants.S_OK)
    {
        // enumerate, find the IVsTextView with a matching filename.
Run Code Online (Sandbox Code Playgroud)

当然还有另一种/更好的方法吗?

提前致谢

〜卡梅伦

add-in visual-studio-2010

13
推荐指数
2
解决办法
4058
查看次数

每个对ResourceDictionary的引用是否都创建了一个新实例,或者ResourceDictionaries是否具有缓存机制

我有一些像这样的代码

        _images = new ResourceDictionary
        {
            Source = new Uri(@"pack://application:,,,/Trilogy.T1TY2012.Transmission;component/Resources/Images.xaml")
        };
Run Code Online (Sandbox Code Playgroud)

在我的应用程序中出现过几次(有时候是C#,有时候是等效的XAML).每个实例是否包含其每个资源的单独实例,或者是否存在跨所有资源字典共享这些资源的幕后缓存机制?

我试图决定是否需要有效地使用资源字典(即:共享特定实例),或者是否已经由WPF处理了此优化.

wpf optimization xaml resourcedictionary

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

WPF动画:检测是否有动画正在进行中?

是否有快速方法来确定WPF控件中的任何动画是否正在处理.

我有一个树视图,我正在动画树节点的扩展,我想等到所有这些动画完成后才能将焦点项目滚动到视图中.我不想独立跟踪所有故事板的进度.

理想情况下,我的伪代码看起来像这样:

myTreeView.ExpandAll(); // I have written this part

while (myTreeView.IsAnimating()) // I need the 'IsAnimating' property or extension method
{
   // wait
}

selectedTreeviewItem.BringIntoView(); // I have written this too.
Run Code Online (Sandbox Code Playgroud)

c# wpf animation

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

VisualStateManager - 显示控件聚焦时的鼠标悬停状态

我正在使用Windows 8样式(以前称为metro)创建WPF按钮.

我希望按钮的聚焦状态以稳固的背景显示.当鼠标悬停在控件上时,我希望背景稍微变暗以创建可以单击按钮的视觉提示.

不幸的是,我在下面写的XAML不起作用.聚焦状态显示正确,但当鼠标在控件上时,背景不会像我希望的那样变暗.

<Color x:Key="DoxCycleGreen">
    #FF8DC63F
</Color>

<!-- Soft Interface : DoxCycle Green --> 
<Color x:Key="DoxCycleGreenSoft">
    #FFC0DC8F
</Color>

<Style x:Key="MetroButton" TargetType="{x:Type Button}">
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Border Name="RootElement">
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup Name="CommonStates">
                            <VisualState Name="Normal" />
                            <VisualState Name="MouseOver">
                                <Storyboard>
                                    <ColorAnimation Storyboard.TargetName="BackgroundColor" Storyboard.TargetProperty="Color" To="{StaticResource DoxCycleGreen}" Duration="0:0:0.150" />
                                    <ColorAnimation Storyboard.TargetName="FontColor" Storyboard.TargetProperty="Color" To="White" Duration="0:0:0.150" />
                                </Storyboard>
                            </VisualState>
                            <VisualState Name="Focused">
                                <Storyboard>
                                    <ColorAnimation Storyboard.TargetName="BackgroundColor" Storyboard.TargetProperty="Color" To="{StaticResource DoxCycleGreenSoft}" Duration="0:0:0.150" />
                                    <ColorAnimation Storyboard.TargetName="FontColor" Storyboard.TargetProperty="Color" To="White" Duration="0:0:0.150" />
                                </Storyboard>
                            </VisualState>
                            <VisualState Name="Pressed">
                                <Storyboard>
                                    <ColorAnimation Storyboard.TargetName="BackgroundColor" …
Run Code Online (Sandbox Code Playgroud)

wpf styling visualstatemanager controltemplate

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

动画WPF窗口宽度和高度

我想设置一个wpf窗口的宽度和高度的动画.我尝试了以下,不幸的是只是动画宽度...窗口的高度永远不会改变.

我确定我错过了一些愚蠢的东西,并希望通过发帖在这里有人会看到我的错误!

这是一个简单窗口背后的代码,其中有一个按钮,我已连接到调整大小:

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        this.AnimateWindowSize(ActualWidth + 200, ActualHeight + 200);
    }
}
Run Code Online (Sandbox Code Playgroud)

以下是我作为扩展方法编写的动画代码,因此它可以应用于任何窗口......

public static class WindowUtilties
{
    public static void AnimateWindowSize(this Window target, double newWidth, double newHeight)
    {
        var sb = new Storyboard {Duration = new Duration(new TimeSpan(0, 0, 0, 0, 200))};

        var aniWidth = new DoubleAnimationUsingKeyFrames();
        var aniHeight = new DoubleAnimationUsingKeyFrames();

        aniWidth.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 200)); …
Run Code Online (Sandbox Code Playgroud)

c# wpf animation

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

在 Roslyn 代码修复中有条件地添加“使用”语句

我正在使用 .NET 编译器 API 在 Roslyn 中编写一些代码分析器/代码修复器。我希望代码修复转换以下代码:

string.Format("{0} {1}", A, B)
Run Code Online (Sandbox Code Playgroud)

StringExtensions.SafeJoin(" ", A, B)
Run Code Online (Sandbox Code Playgroud)

到目前为止,我有这个代码:

private async Task<Document> UseJoinAsync(Document document, InvocationExpressionSyntax invocationExpr, CancellationToken cancellationToken)
{
    var argumentList = invocationExpr.ArgumentList;
    var firstArgument = argumentList.Arguments[1];
    var secondArgument = argumentList.Arguments[2];

    var statement =
        InvocationExpression(
                MemberAccessExpression(
                    SyntaxKind.SimpleMemberAccessExpression,
                    IdentifierName("StringExtensions"), // requires using Trilogy.Miscellaneous
                    IdentifierName("SafeJoin")))
            .WithArgumentList(
                ArgumentList(
                    SeparatedList<ArgumentSyntax>(
                        new SyntaxNodeOrToken[]
                        {
                            Argument(
                                LiteralExpression(
                                    SyntaxKind.StringLiteralExpression,
                                    Literal(" "))),
                            Token(SyntaxKind.CommaToken),
                            firstArgument,
                            Token(SyntaxKind.CommaToken),
                            secondArgument
                        }))).WithLeadingTrivia(invocationExpr.GetLeadingTrivia()).WithTrailingTrivia(invocationExpr.GetTrailingTrivia())
            .WithAdditionalAnnotations(Formatter.Annotation);

    var root = await document.GetSyntaxRootAsync(cancellationToken);

    var newRoot = root.ReplaceNode(invocationExpr, statement);

    var newDocument …
Run Code Online (Sandbox Code Playgroud)

c# roslyn roslyn-code-analysis

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

TFS 2010备份失败,并显示"当前用户名无法检索MSSQL Server服务帐户".

我正在尝试使用2011年3月发布的TFS 2010 Power Tools备份我的TFS 2010实例.

在验证步骤中,我收到一条错误,我不知道如何解决:

"当前用户名无法检索MSSQL Server服务帐户."

有人可以帮忙吗?

sql backup tfs tfs2010

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

FreezableCollection 在子属性更改时不提供更改通知

我有一个 FreezableCollection,我想监视其子属性的更改。这是代码的一小部分:

public class FieldHeading : DependencyObject
{
    public static readonly DependencyProperty LayoutProperty = DependencyProperty.Register("Layout", typeof(FieldHeadingLayout), typeof(FieldHeading),
        new FrameworkPropertyMetadata(FieldHeadingLayout.Above,
        FrameworkPropertyMetadataOptions.AffectsRender |
        FrameworkPropertyMetadataOptions.AffectsMeasure |
        FrameworkPropertyMetadataOptions.AffectsParentMeasure));

    public FieldHeadingLayout Layout
    {
        get { return (FieldHeadingLayout) GetValue(LayoutProperty); }
        set { SetValue(LayoutProperty, value); }
    }

}

public class FieldPanel : FrameworkElement
{
    private static readonly DependencyProperty FieldHeadingProperty = DependencyProperty.Register("FieldHeading", typeof(FreezableCollection<FieldHeading>), typeof(FieldPanel),
        new FrameworkPropertyMetadata(null,
            FrameworkPropertyMetadataOptions.AffectsMeasure |
            FrameworkPropertyMetadataOptions.AffectsParentMeasure |
            FrameworkPropertyMetadataOptions.AffectsRender, HeadingChanged));

    private static void HeadingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        Debug.WriteLine("Hello");
    }

    public FreezableCollection<FieldHeading> FieldHeadings
    {
        get
        { …
Run Code Online (Sandbox Code Playgroud)

c# collections wpf notifications

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