小编Ver*_*int的帖子

WPF循环进度条

我想ProgressBar用圆圈替换常规,在镜头搜索后在论坛中我找到了我想要的东西.

CircularProgressBar.XAML

<Grid>
    <Path x:Name="pathRoot" Stroke="{Binding SegmentColor, ElementName=userControl}" 
          StrokeThickness="{Binding StrokeThickness, ElementName=userControl}" HorizontalAlignment="Left" VerticalAlignment="Top">
        <Path.Data>
            <PathGeometry>
                <PathGeometry.Figures>
                    <PathFigureCollection>
                        <PathFigure x:Name="pathFigure">
                            <PathFigure.Segments>
                                <PathSegmentCollection>
                                    <ArcSegment x:Name="arcSegment" SweepDirection="Clockwise" />
                                </PathSegmentCollection>
                            </PathFigure.Segments>
                        </PathFigure>
                    </PathFigureCollection>
                </PathGeometry.Figures>
            </PathGeometry>
        </Path.Data>
    </Path>
</Grid>
Run Code Online (Sandbox Code Playgroud)

CircularProgressBar.cs:

public partial class CircularProgressBar : UserControl
{
    public CircularProgressBar()
    {
        InitializeComponent();
        Angle = (Percentage * 360) / 100;
        RenderArc();
    }

    public int Radius
    {
        get { return (int)GetValue(RadiusProperty); }
        set { SetValue(RadiusProperty, value); }
    }

    public Brush SegmentColor
    {
        get { return (Brush)GetValue(SegmentColorProperty); …
Run Code Online (Sandbox Code Playgroud)

wpf geometry progress-bar

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

WPF:为什么我的前景颜色在不同的OS下看起来不同

我有WPF申请ListViewProgressBar内部.我定义这个颜色,Foreground我的ProgressBar:

在此输入图像描述

Windows 8我可以看到这种颜色,但在Windows 7我可以看到不同的颜色:

在此输入图像描述

所以我的问题是有可能在所有操作系统中看到我的欲望颜色吗?

编辑:

这是我创建的风格:

<Style x:Key="CustomProgressBar" TargetType="ProgressBar" >
    <Setter Property="Foreground" Value="#FF15669E"></Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)

这是我的ProgressBar:

<ProgressBar Name="prog" Maximum="100" Value="{Binding Progress}" 
             Width="{Binding Path=Width, ElementName=ProgressCell}" Background="#FFD3D0D0" Style="{StaticResource CustomProgressBar}"/>
Run Code Online (Sandbox Code Playgroud)

但颜色没有改变.

wpf

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

WPF; 如何在ListView中单击空白区域时取消选择所有选定的项目

当我有几个(甚至一个)selected items并且我click在我的ListView空空间(简单空格=不是行)上按简单时我想取消选择我所有选定的项目.

这是我取消选择所有项目功能:

private void DeselectAllListViewItems()
{
    MyListView.SelectedItems.Clear();
} 
Run Code Online (Sandbox Code Playgroud)

我尝试使用此函数获取所选索引:

private void MyListView_MouseDown(object sender, MouseButtonEventArgs e)
{
    if (MyListView.SelectedIndex == -1)
        DeselectAllListViewItems();
}
Run Code Online (Sandbox Code Playgroud)

但是如果我有几个选定的项目(或一个..),所选的索引永远不会是-1.那么我如何区分我的mouse click空位而不是项目排?

wpf listview

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

标签 统计

wpf ×3

geometry ×1

listview ×1

progress-bar ×1