小编Dav*_*mer的帖子

更改最小化,关闭和最大化窗口的图标

简单的问题.如何更改关闭,最小化,最大化按钮的图标.我可以在Winforms和WPF中执行此操作吗?

c# wpf icons window winforms

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

如何获取UIElement的父Popup?

我对下面的标记有两个问题:

<Popup>
    <Button x:Name="button"/>
</Popup>
Run Code Online (Sandbox Code Playgroud)
  1. 为什么VisualTreeHelper.GetParent(button)返回null?
  2. 我怎样才能得到父母Popup的UIElement?

silverlight popup uielement

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

如何覆盖Dictionary的ToString()

我有一个Dictionary<string, FieldDefinition>依赖属性,当我将它绑定到WPF列表框时,我希望它只打印字符串(而不是FieldDefinition).

有没有办法做到这一点?

.net c# wpf dictionary tostring

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

在WPF中访问XAML控件

我在.xaml中使用此代码,因为我创建了一个用户定义的控件(TextBox)NumericTextbox:

<local:NumericTextBox Grid.Column="1"
       local:NumericTextBox.Mask="Decimal"
       local:NumericTextBox.MaximumValue="55"
       local:NumericTextBox.MinimumValue="0"
       Name="abc"
       Grid.Row="0"
       Text="{Binding Path=IPAddressProperty}" />
Run Code Online (Sandbox Code Playgroud)

我想NumericTextbox在.xaml.cs中访问它,我必须在.xaml.cs文件中给出最小值和最大值,

有人可以帮帮我吗?

c# wpf xaml controls textbox

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


子控件的宽度应与父容器的宽度匹配

我对WPF很新.我经常发现自己正在努力获得一堆子控件组合宽度以匹配给定的父容器.如下所示:

<ListBox x:Name="BrugereListBox" Grid.Column="0" Grid.Row="3" DataContext="{DynamicResource Brugere}" 
             ItemsSource="{Binding}" 
             PreviewMouseLeftButtonDown="BrugereListBox_MouseLeftButtonDown"
             PreviewMouseMove="BrugereListBox_PreviewMouseMove"
             >
        <ListBox.ItemTemplate  >
            <DataTemplate >
                <Border BorderBrush="Black" BorderThickness="1" Margin="2">
                    <StackPanel Orientation="Vertical" IsEnabled="True" 
                                PreviewMouseLeftButtonDown="StackPanel_PreviewMouseLeftButtonDown">
                        <StackPanel Orientation="Horizontal" >
                            <Label>Navn</Label>
                            <TextBox Text="{Binding Name}"></TextBox>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Label>Password</Label>
                            <TextBox Text="{Binding Password}"></TextBox>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Label>Email</Label>
                            <TextBox Text="{Binding Email}"></TextBox>
                        </StackPanel>
                    </StackPanel>
                </Border>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我有兴趣获得stackpanel的子节点的宽度:

<StackPanel Orientation="Horizontal" >
                        <Label>Navn</Label>
                        <TextBox Text="{Binding Name}"></TextBox>
                    </StackPanel>
Run Code Online (Sandbox Code Playgroud)

匹配的宽度

<ListBox x:Name="BrugereListBox"
Run Code Online (Sandbox Code Playgroud)

像这样的场景的任何通用解决方案?

wpf controls parent width

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

限制Items控件中显示的行数

有没有办法限制在项目控件中显示的行数。?

我有一个绑定到 Items 控件的可观察字符串集合。我想将要显示的行数限制为一。集合可以有多个。

谢谢,

wpf binding itemscontrol wpf-controls

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

在wpf窗口中删除事件处理程序

在我们的wpf应用程序中,我们在窗口的构造函数中添加事件,如下所示:

AddHandler(Keyboard.KeyUpEvent, (KeyEventHandler)HandleKeyDownEvent);

        this.Closing += new System.ComponentModel.CancelEventHandler(WindowF_Closing);
        this.Loaded += new RoutedEventHandler(WindowF_Loaded);
Run Code Online (Sandbox Code Playgroud)

在关闭事件中删除这些事件以便放置窗口是一个好主意:

RemoveHandler(Keyboard.KeyUpEvent, (KeyEventHandler)HandleKeyDownEvent);

        this.Closing -= new System.ComponentModel.CancelEventHandler(WindowF_Closing);
        this.Loaded -= new RoutedEventHandler(WindowF_Loaded);
Run Code Online (Sandbox Code Playgroud)

wpf window event-handling

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

如何检查线程,然后填写C#/ WPF中的进度条

我正在开发我在Windows上的第一个GUI应用程序.

我有一个WPF GUI到一个复制文件的小型C#实用程序.单击按钮进行复制时,我显然不希望GUI挂起.因此,我启动一个新线程来运行复制文件的方法.我认为到目前为止我已经走上正轨,并且在C#中没有"更好"的方式吗?

现在,我有一个ProgressBar我希望在线程完成时显示的内容.(现在它运行良好,不确定).如何检查复制何时完成?

所以,到目前为止,我有:

Thread t = new Thread(delegate() 
{ 
    po.Organise(inputPath, outputPath, recursive); 
});

t.Start();

PBar.IsIndeterminate = true;
Run Code Online (Sandbox Code Playgroud)

之后我想要的东西就像:

if (t.Done)
{
    PBar.Value = 100;
}
Run Code Online (Sandbox Code Playgroud)

c# wpf multithreading progress-bar

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

如何将动态文本添加为​​任务栏图标叠加?

我正在尝试将带有文本的任务栏图标叠加添加到windows7应用程序图标,我确实设法添加小叠加但无法添加文本.

有没有人知道如何添加动态文本作为任务栏图标叠加?

使用:WPF和C#

c# wpf icons taskbar windows-7

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