小编Dav*_*mer的帖子

谷歌Chrome/Windows 7对WPF的影响?

Windows 7窗口自然有一个半透明的标题.我刚刚意识到谷歌Chrome TabBar与这种效果混合,好像TabBar背景和窗口标题是一样的!非常酷!

有没有办法在WPF中获得相同的结果?任何例子?

谢谢.

.net c# wpf styles google-chrome

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

以编程方式更改选定的ListBoxItem

是否可以ListBoxItem在Windows Presentation Foundation中更改从Code-Behind中选择的内容?

这是一个很简单的任务真的,我有一个NextPrevious按钮,它们代表了下一个和上一个项目ListBox.但是,myListBox.items当然是我存储在内容中的对象表示ListBox.

那么,如何获取ListBoxItem设置IsSelected属性?

c# wpf listbox selecteditem listboxitem

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

WPF DropShadowEffect with allowsTransparency ="True"

我想在上面创建非矩形窗口DropShadowEffect.我发现这篇文章是怎么做到的.但DropShadowEffect运行此代码时未显示.在屏幕截图中,您可以看到它DropShadowEffect存在,但它不适合我.

我怎么可以使用DropShadowEffectAllowsTransparency设置为TRUE?

wpf styles dropshadow

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

将ContentPresenter.Content强制转换为UIElement是否合适?

是否有任何情况下a的内容ContentPresenter将是某个对象而不是UIElement?鉴于该字段被声明为对象而不是a UIElement,似乎可能存在.但是,我想不出它会出现的任何情况,或者即使它是有效的.

ContentPresenter presenter = GetTemplateChild(PART_Presenter) as ContentPresenter;
UIElement myElement = (UIElement)presenter.Content;
myElement.SomeUIMethod(); // possible InvalidOperationException?
Run Code Online (Sandbox Code Playgroud)

c# wpf contentpresenter uielement

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

如何在WPF中播放声音

我是新手C#程序员,在使用VS 2008在我的WPF(Windows)应用程序中播放音乐时遇到了麻烦.这是一个Web应用程序.我认为发生的myMediaElementExample变量是在用于执行文件中的Play方法时为空ExpenseReportPage.xaml.cs.

现在这个程序构建,但是在我运行之后,它遇到了一个异常myMediaElementExample.Play();.例外说:

An unhandled win32 exception occurred in the WpfApplication1.vhost.exe [948].
Run Code Online (Sandbox Code Playgroud)

你能不能给我一些关于我可能尝试的其他建议?我只包含了与此问题相关的代码:

ExpenseReportPage.xaml.cs文件:

namespace ExpenseIt
{
    public partial class ExpenseReportPage : Page
    {
...    }

    public partial class MediaElementExample : Page
    {
        MediaElement myMediaElementExample = new MediaElement();

        public MediaElementExample()
        {
         }

        public void OnMouseDownPlayMedia(object sender, RoutedEventArgs args) //MouseButtonEventArgs
        {
            // The Play method will begin the media if it is not currently active or 
            // resume media if it is paused. …
Run Code Online (Sandbox Code Playgroud)

.net c# audio wpf mediaelement

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

如何在WPF表单中为BackgroundImage设置图像?

在Windows窗体中,我会去BackgroundImage,只需从comboBox中选择它.但这里没有这样的财产.

我该怎么做?

c# forms wpf background-image

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

在WPF项目中更改Main

总是烦恼我C#想要为你做这个创业公司.所以现在我正在尝试制作自己的主要方法.它不起作用:

我提供了这个主要方法:

[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static void Main()
{
    Model model= new Model();
    Controller controller = new Controller(model);
    MainWindow window = new MainWindow(controller, model);
}
Run Code Online (Sandbox Code Playgroud)

这个方法运行,但我看不到任何视觉效果.我想我错过了以下正常主要代码:

Application.App app = new Application.App();
app.InitializeComponent();
app.Run();
Run Code Online (Sandbox Code Playgroud)

我尝试使用相同的代码覆盖OnStartUp,但是会引发异常.如果您有其他解决方案,我愿意听.我只是不明白为什么我的MainWindow必须先创建.

.net c# wpf model-view-controller program-entry-point

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

WPF条件绑定

我有TreeView一些像TextBoxes和ComboBoxes 这样的其他控件.在TextBoxES绑定到所选的项目,TreeView就像这样:

Text="{Binding SelectedItem.Name, ElementName=groupTreeView}"
Run Code Online (Sandbox Code Playgroud)

如果我的所有元素TreeView都有一个Name属性,这可以正常工作.

我想知道是否有办法做某种条件绑定会说:

if SelectedItem is MyTreeType
    then bind
else
    disable the element
Run Code Online (Sandbox Code Playgroud)

可以这样做吗?现在我只是抛出绑定错误而且看起来有点脏.我TreeView是数据绑定,并且有几个不同类型的类,所以这就是为什么我正在寻找某种条件绑定.

谢谢,劳尔

data-binding wpf conditional

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

WPF:如何将自定义格式应用于ListView?

我的ListView很简单:

<ListView ItemsSource="{Binding Path=ActiveCounters}">
    <ListView.View>
        <GridView>
            <GridViewColumn  Header="Name" DisplayMemberBinding="{Binding Path=Name}" />
            <GridViewColumn  Header="Value"  DisplayMemberBinding="{Binding Path=Value}" />
            <GridViewColumn  Header="As Of Date"  DisplayMemberBinding="{Binding Path=AsOfDate}" />
            <GridViewColumn  Header="Duration"  DisplayMemberBinding="{Binding Path=Duration}" />
            <GridViewColumn  Header="Last Modified Date"  DisplayMemberBinding="{Binding Path=Timestamp}" />
        </GridView>
    </ListView.View>
</ListView>
Run Code Online (Sandbox Code Playgroud)

我想做的是:

  • 使用内置格式"D0"格式化"值"
  • 使用自定义字符串"MMM d hh:mm:ss tt"格式化"AsOfDate"和"Last Modified Date"
  • 使用定义为"String DurationString(TimeSpan)的函数格式化"Duration"

wpf formatting binding listview styles

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

如何绑定到文本框

我的XAML是

<TextBox Name="DutchName" HorizontalAlignment="Right" Text="{Binding customer,Path=DutchName }" />
Run Code Online (Sandbox Code Playgroud)

我的班级是

class customer
{
    Name name;
}

class Name
{
    string DutchName;
    string EnglishName;
}
Run Code Online (Sandbox Code Playgroud)

TextBox未绑定.任何人都可以纠正这个错误吗?

谢谢,

c# data-binding wpf textbox .net-3.5

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