小编M. *_*ley的帖子

名为XAML Geometry属性的字母是什么?

我正在定义一个XAML DrawingBrush资源,我想绘制一个自定义形状.我找到了以下GeometryDrawing示例:

<GeometryDrawing Geometry="M0,0.1 L0.1,0 1,0.9, 0.9,1z" Brush="Gray" />
Run Code Online (Sandbox Code Playgroud)

做什么的M,L以及z在信件Geometry的属性是什么意思?他们叫什么?

wpf drawing shape geometrydrawing

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

Microsoft.Win32.OpenFileDialog.ShowDialog()何时返回null?

OpenFileDialogShowDialog方法返回一个可以为空的布尔值,如果用户单击OK则设置为true,如果单击Cancel,则设置为false.什么时候回来null?文档没有说.

wpf winapi openfiledialog savefiledialog

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

WPF TreeView中节点之间的行

我想知道的是,如果有一种简单的方法来添加连接WPF TreeView中节点的行,就像Visual Studio 2008的解决方案资源管理器窗格一样.我找到了一个解决方案,但是有很多代码,我想要一个更简单的方法.一个线程在微软的Silverlight论坛似乎表明,缺乏一个"行"的选择是由于Silverlight的兼容性.

wpf treeview

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

在WPF中对ToggleButton的IsChecked属性进行OneWay绑定

我有一个ToggleButton与它的IsChecked属性绑定到使用单向绑定属性.

<ToggleButton
    Command="{Binding Path=SomeCommand}"
    IsChecked="{Binding Path=SomeProperty, Mode=OneWay}" />
Run Code Online (Sandbox Code Playgroud)

SomeCommand切换布尔SomeProperty值,一个PropertyChanged事件引发的SomeProperty.

如果我更改SomeProperty了我的viewmodel,ToggleButton则会正确压下.但是,如果我单击该ToggleButton绑定似乎丢失,并且不再根据值来检查该按钮SomeProperty.关于如何解决这个问题的任何想法?

data-binding wpf togglebutton

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

我在哪里可以下载Microsoft的标准WPF主题?

微软已经将WPF的Classic,Luna,Royale和Aero主题作为XAML资源词典下载.

我在哪里可以下载它们?我永远找不到链接!

wpf xaml themes

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

是否可以在C#中使用未绑定类型作为泛型类型参数?

我有一个C#泛型:

public class Generic<TParameter> { ... }
Run Code Online (Sandbox Code Playgroud)

似乎我不能使用未绑定的类型作为类型参数.我error CS1031: Type expected尝试以下时得到:

var lGenericInstance = new Generic<List<>>();
Run Code Online (Sandbox Code Playgroud)

如何将未绑定类型用作泛型类型参数?有变通方法吗?我的泛型类只是使用反射,所以我可以获得所提供类型的成员列表作为字符串.


更新:我的答案是关于未绑定类型的问题,所以我已经跟进了一个单独的问题来解决我的具体问题.

c# generics

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

为模拟的std :: fstream类避免"优势继承"警告

我正在使用googlemockstd::fstream在我的单元测试中模拟出一个对象,如下所示:

TEST_F(SomeTest, SomethingIsDoneCorrectly)
{
    class MockFstream : public std::fstream {};
    MockFstream lMockFstream;
    // Expectations and assertions here
}
Run Code Online (Sandbox Code Playgroud)

当我编译时,我得到以下警告:

警告1警告C4250:'SomeTest_SomethingIsDoneCorrectly_Test :: TestBody :: MockFstream':通过优势继承'std :: basic_istream <_Elem,_Traits> :: std :: basic_istream <_Elem,_Traits> :: _ Add_vtordisp1'

警告2警告C4250:'SomeTest_SomethingIsDoneCorrectly_Test :: TestBody :: MockFstream':通过优势继承'std :: basic_ostream <_Elem,_Traits> :: std :: basic_ostream <_Elem,_Traits> :: _ Add_vtordisp2'

我更喜欢干净的构建输出,所以我想要抑制这些特定的警告,但我正在编写跨平台代码,所以我也更愿意避免使用特定于编译器的#pragmas.

我可以在googlemock对象中做些什么来隐藏这些警告吗?

c++ fstream mocking compiler-warnings visual-c++

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

WPF TextBlock填充正在切断文本

我有一个TextBlockGridPadding属性设置为5,有时候最后一个字符被切断,这取决于字符串Text属性设置为.

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SomeClass">
    <ScrollViewer Padding="5" VerticalScrollBarVisibility="Auto">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Label
                Grid.Row="0" Grid.Column="0"
                Content="SomeLabel"
                HorizontalAlignment="Right"
                HorizontalContentAlignment="Right"
                VerticalAlignment="Center" />
            <TextBlock
                Grid.Row="0" Grid.Column="1"
                HorizontalAlignment="Left"
                Padding="5"
                Text="0x0F"
                TextWrapping="Wrap"
                VerticalAlignment="Top" />
        </Grid>
    </ScrollViewer>
</UserControl>
Run Code Online (Sandbox Code Playgroud)

Text设置为0x0FF不可见.当它设置为0xAB字符串显示就好了.设置Padding为0也使字符串显示正常.

wpf textblock padding

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

从ResourceDictionary中绑定到祖先

我如何UserControl从其内部绑定一个属性ResourceDictionary?我想要一个我在我的资源中声明的对象DataContextUserControl它包含在的对象相同:

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Some.Namespace"
    DataContext="{Binding Path=ViewModel, RelativeSource={RelativeSource Self}}">
    <UserControl.Resources>
        <local:SomeClass
            x:Key="SomeClass"
            DataContext="{Binding Path=DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" />
    </UserControl.Resources>
</UserControl>
Run Code Online (Sandbox Code Playgroud)

在运行时我收到错误:

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='UserControl', AncestorLevel='1''. BindingExpression:Path=DataContext; DataItem=null; target element is 'SomeClass' (Name=''); target property is 'DataContext' (type 'Object')

wpf xaml binding resourcedictionary

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

超时单元测试

我是一个单元测试类的属性,其值经常变化,这取决于它从另一个组件接收的通信.如果该类在5秒内未收到任何通信,则该属性将恢复为默认值.

我很容易存根和模拟通信组件​​,以便触发我想要测试的值.问题是如果我在繁忙的机器上运行我的单元测试(比如构建机器),并且有足够的延迟导致属性默认,那么我的单元测试将失败.

在模拟各种通信条件时,您将如何测试以确保此属性具有适当的值?

一个想法是重构我的代码,以便我可以存根控制超时的类的部分.另一种方法是编写我的单元测试,以便它可以检测是否由于超时而失败并在测试结果中指出.

unit-testing timeout

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