小编Sim*_* D.的帖子

卸载ReSharper 4.5

我在Visual Studio 2008中有ReSharper 4.5.现在我想安装ReSharper 5,但在卸载ReSharper 4.5之前我无法做到.

如何卸载ReSharper 4.5?

resharper installation failed-installation visual-studio-2008 visual-studio

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

如何使Resharper解析CustomBinding MarkupExtension的路径

我想创建一些扩展的Binding-Markup-Extension,它的行为就像普通的WPF-Binding一样,但做的更多(使用不同的默认值,可能会添加一些行为等).代码如下所示:

public class CustomBindingExtension : Binding
{
  .. some extra properties and maybe overrides ...
}
Run Code Online (Sandbox Code Playgroud)

这一切都很好,包括XAML-intellisense,除了我不能让Resharper正确解析我的Binding-Path.即:使用此代码我可以[Strg] +单击'CurrentText',Resharper让vs2010导航到定义CurrentText-Property的代码.

<UserControl x:Name="uc" ...>
  <TextBox Text="{Binding ViewModel.CurrentText, ElementName=uc}" />
</UserControl>
Run Code Online (Sandbox Code Playgroud)

但是使用我的绑定,它在运行时正常工作,我只是在悬停'CurrentText'时得到一个工具提示告诉我它是'MS.Internal.Design.Metadata.ReflectionTypeNode',并且没有通过[Strg] + Click导航.

<UserControl x:Name="uc" ...>
  <TextBox Text="{util:CustomBinding ViewModel.CurrentText, ElementName=uc}" />
</UserControl>
Run Code Online (Sandbox Code Playgroud)

我尝试了以下事项:

  • 从绑定派生
  • BindingDecoratorBase派生
  • 省略我的CustomBinding类的'Extension'后缀
  • 将Markup-Extension放在一个单独的程序集中
  • 使用ConstructorArgumentAttribute
  • 类型字符串的属性和Path-Property的类型PropertyPath
  • 我还查看了原始类Binding和BindingBase,但找不到我的代码的任何更多差异.任何想法应该有什么帮助?或者这只是对Binding-MarkupExtension的特殊处理,我无法获得自己的MarkupExtensions?

    更新2011年3月16日:也可能是错误或ReSharper的不足,Jetbrains的正在调查该问题:http://youtrack.jetbrains.net/issue/RSRP-230607

    更新10.12.2013:同时,该功能似乎正在工作(使用R#7.1.3,也许是早期版本),我实际上使用BindingDecoratorBase的方法,我非常喜欢它.也许它只有作用,如果你的MarkupExtension结束'Binding',但我的确如此,所以我很高兴.

    wpf resharper xaml visual-studio-2010 markup-extensions

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

    如何实现focus-reset以在任何操作之前更新TextBox的BindingSource

    当我无法使用UpdateTrigger = PropertyChanged进行绑定时,我观察到绑定到textproperties的文本框的一些意外或至少不完全匹配的my-needs行为.可能它不是文本框的问题,但也会与其他编辑器一起出现.

    在我的示例(附带源代码)中,我有一个绑定到某个集合的WPF TabControl.在每个选项卡上,您可以从集合中编辑项目,以各种方式触发保存操作,这应该将编辑保存到某个模型.绑定到每个项目属性的文本框(有意)保持默认更新触发器'OnFocusLost'.这是因为在设置新值时会发生一些昂贵的验证.

    现在我发现至少有两种方法可以以这种方式触发我的保存操作,即最后一个聚焦文本框不会更新绑定值.1)通过鼠标单击其标题更改选项卡项,然后单击某个保存按钮.(更改回上一个选项卡显示新值甚至丢失)2)通过KeyGesture触发save-command.

    我设置了一个演示行为的示例应用程序.单击"全部保存"将显示所有项目值,另一个保存按钮仅显示当前项目.

    问:在绑定对象被调用之前,确保所有文本框的所有绑定源都会更新的最佳方法是什么?最好应该采用一种方式捕捉所有可能性,我不喜欢以不同的方式捕捉每个事件,因为我担心会忘记一些事件.例如,观察选项卡控件的选择更改事件将解决问题1)但不解决问题2).

    现在举例:

    XAML首先:

    <Window x:Class="TestOMat.TestWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:TestOMat="clr-namespace:TestOMat"
    Title="TestOMat" x:Name="wnd">
    <Grid>
        <Grid.Resources>
            <DataTemplate x:Key="dtPerson" DataType="{x:Type TestOMat:Person}">
                <StackPanel Orientation="Vertical">
                    <StackPanel.CommandBindings>
                        <CommandBinding Command="Close" Executed="CmdSaveExecuted"/>
                    </StackPanel.CommandBindings>
                    <TextBox Text="{Binding FirstName}"/>
                    <TextBox Text="{Binding LastName}"/>
                    <Button Command="ApplicationCommands.Stop" CommandParameter="{Binding}">Save</Button>
                </StackPanel>
            </DataTemplate>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.CommandBindings>
            <CommandBinding Command="ApplicationCommands.Stop" Executed="CmdSaveAllExecuted"/>
        </Grid.CommandBindings>
        <TabControl ItemsSource="{Binding ElementName=wnd, Path=Persons}" ContentTemplate="{StaticResource dtPerson}" SelectionChanged="TabControl_SelectionChanged"/>
        <Button Grid.Row="1" Command="ApplicationCommands.Stop">Save All</Button>
    </Grid></Window>
    
    Run Code Online (Sandbox Code Playgroud)

    和相应的课程

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows;
    using System.Windows.Controls;
    namespace TestOMat
    {
      /// <summary> …
    Run Code Online (Sandbox Code Playgroud)

    c# data-binding wpf textbox focus

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

    如何使用SharpSvn从SVN-external中的相对URI正确检索SVN-Info

    我有一个Powershell Cmdlet,它通过SharpSvn从主干创建SVN-Branches.存储库包含明确设置有和没有revision/pegRevision的外部.在分支中,没有修订集的所有外部应该在分支创建时进行HEAD修订,未来的更改不会影响分支.

    因此,我将external-info解压缩SharpSvn.SvnExternalItem并查询存储库,以查找使用的每个外部找到的当前HEAD修订版SharpSvn.SvnClient.GetInfo(SvnTarget externalTarget, out SvnInfoEventArgs info)

    因此,我需要一种强大的方法来从ExternalInfo到SvnTarget(或直接到修订信息).我不想限制外部URI的格式,即此处显示的所有可能性应该有效.SharpSvn中是否有一个干净的解决方案来将所有这些类型的URI解析为绝对URI或另一种检索其最新版本的方法?

    例如,这样的事情会很棒(我知道我的外部uri和定义外部的目录的绝对URI,这对于相对URI肯定是必需的):

    public SvnTarget ResolveExternalUri(SvnUriTarget aOwningDirectory, string aExternalReferenceUri) {
      // yeah, I know this does not exist (yet?)
      return SvnUri.Combine(aOwningDirectory.Uri, aExternalRefferenceUri);
    }
    
    Run Code Online (Sandbox Code Playgroud)

    目前我只是自己解析外部URI字符串,检查它是相对的还是绝对的并且处理那些'^'和'//'前缀,但我不确定我是否支持所有变体而且我认为这应该是一个很常见的任务,已经可以通过SvnClient-lib中的一些隐藏的gem来解决.

    c# svn powershell external sharpsvn

    10
    推荐指数
    0
    解决办法
    944
    查看次数

    通过DataTemplate为WPF-ComboBoxItem设置TextSearch.Text

    我使用datatemplate来可视化ComboBox中的一些项目,ItemsSource绑定到ObservableCollection.为了简单起见,让我说我把人放入ObservableCollection:

    public class Person {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
    
    Run Code Online (Sandbox Code Playgroud)

    我的DataTemplate看起来像这样:

    <DataTemplate TargetType="{x:Type Person}">
      <StackPanel Orientation="Horizontal">
        <TextSearch.Text>
          <MultiBinding StringFormat="{} {0} {1}">
            <Binding Path="FirstName"/>
            <Binding Path="LastName"/>
          </MultiBinding>
        </TextSearch.Text>
        <TextBlock Text="{Binding FirstName}" Margin="2,0" />
        <TextBlock Text="{Binding LastName}"/>
      </StackPanel>
    </DataTemplate>
    
    Run Code Online (Sandbox Code Playgroud)

    现在我想在ComboBox中为全名启用自动完成功能,而不在我的person类上引入第三个属性.因此我不想在ComboBox上使用TextSearch.TextPath属性,而是想在DataTemplate中绑定每个ComboBoxItem的TextSearch.Text-Property.不幸的是,当我这样做(使用MultiBinding和StringFormat,使用Snoop测试)时,绑定值仅为我的StackPanel注册,但是使用Snoop(很棒的工具)我发现这个stackpanel就像其他一些ComboBoxItemTemplate的内容一样,它放置另一个边框等,最后一个ComboBoxItem标签围绕我的外部StackPanel.因此,TextSearch.Text设置无效,因为它必须在创建的ComboBoxItem中设置,而不是在其中的某个位置.

    现在问题:如何使用XAML-Styles和-Control-Templates将我的DataTemplate中的TextSearch.Text-Property传播到周围的ComboBoxItem?该解决方案可能会修改ComboBox和ComboBoxItem的默认ControlTemplates以及我的自定义(Item-)DataTemplate,但不会使用任何Code-Behind,或者至少不会太多.也许附加的行为也可以.但我几乎肯定必须有一种方法可以让它无需工作,TemplateBinding或RelativeSource-stuff ......当然,解决方案必须使我的键盘选择和文本完成工作,s.当名单中包含汉斯约瑟夫和汉斯彼得,然后进入'汉斯'应该自动提出汉斯约瑟夫,而进入'汉斯P'足够快应该自动提出汉斯彼得.

    有解决方案吗

    c# data-binding wpf combobox datatemplate

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

    覆盖任务栏命令"关闭所有Windows"的处理

    我有一个WPF应用程序与多个不相关的Windows,即总有一个MainWindow和任选许多其他没有所有者.如果这些窗口在任务栏中分组,则窗口将在任务栏上下文菜单中提供"关闭所有Windows"操作.如果单击它,我的应用程序的每个窗口都会按照我无法控制的顺序获得单独的关闭命令.

    问题:如果可以取消挂起的更改,我的一些窗口可能会在关闭之前询问.如果有很多这样的话,这很烦人并且令人困惑.

    我想要的是:如果要求关闭MainWindow,我想提示一次,如果没关系的话.如果是,所有窗口应该静默关闭,否则保持打开状态.但我的MainWindow不是第一个处理结束程序的人.

    我已经发现,我可能需要使用wparam SC_CLOSE检查我的MainWindow的Windows消息循环中的某些WM_SYSCOMMAND.(请参阅如何在使用Windows 7的MFC中区分"关闭所有Windows"和"关闭"各个窗口?)

    但是,在执行任何其他窗口的关闭例程之前,我该如何评估它呢? ComponentDispatcher.ThreadPreprocessMessage在我的主窗口来得太晚了,它在一些其他窗口开始关闭程序后触发.

    这个问题在某种程度上与这个问题有关: 当使用任务栏的关闭所有Windows时,奇怪的表格关闭行为

    c# wpf

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

    YesNo MessageBox在单击x按钮时未关闭

    当我打开带有选项YesNo的MessageBox时,右上角的(通常)取消交叉显示但没有效果.

    System.Windows.MessageBox.Show("Really, really?", "Are you sure?", MessageBoxButton.YesNo);
    
    Run Code Online (Sandbox Code Playgroud)

    如果我提供YesNoCancel作为选项,单击十字会​​关闭Dialog DialogResult取消.

    System.Windows.MessageBox.Show("Really, really?", "Are you sure?", MessageBoxButton.YesNoCancel);
    
    Run Code Online (Sandbox Code Playgroud)

    如果没有隐藏,我会期望十字架"看起来已禁用",当点击它时没有效果.可能我不是第一个观察到这一点的人.您最喜欢隐藏/禁用此按钮或解决问题的方法是什么?

    注意:我更喜欢不使用System.Windows.Forms的解决方案,因为我正在处理WPF项目,并希望尽可能避免任何InterOp.

    .net wpf messagebox

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