好吧,我正在使用WPF为我的MP3播放器制作一个GUI,我有一个边框,可以为播放曲目的每一秒扩大其宽度属性,从而为当前播放的歌曲制作一个"进度条".我将边框命名为ProgressBarBorder.整个播放列表完成后,我想使用DoubleAnimation淡出边框.现在,如果我再次启动播放器,边框会响应它的意思(意味着宽度从0开始并进展到歌曲的结尾),但是出于某种奇怪原因的不透明度属性保持为0.0(即DoubleAnimation的值)套).我已明确编码
ProgressBarBorder.Opacity = 1.0;
Run Code Online (Sandbox Code Playgroud)
在开始播放的方法中.然而,它保持隐形.现在,如果我不使用DoubleAnimation而只是写
ProgressBarBorder.Opacity = 0.0;
Run Code Online (Sandbox Code Playgroud)
播放列表完成后,当我再次启动播放器时,它会返回1.0.这就是为什么我肯定动画是造成问题的动画的原因.此外,在动画结束后,该属性是不是应该回到它的原始状态?如果是,我的边框应在动画完成后自动显示.
这是我的部分伪代码:
if (TrackIsComplete)
{
DoubleAnimation Fading = new DoubleAnimation();
Fading.From = 1.0;
Fading.To = 0.0;
Fading.Duration = TimeSpan.FromSeconds(3);
ProgressBarBorder.BeginAnimation(Border.OpacityProperty, Fading);
}
Run Code Online (Sandbox Code Playgroud)
和
private void PlayTrack()
{
ProgressBarBorder.Opacity = 1.0;
Play();
....
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?谢谢.
使用PRISM时,使用unity来连接事物的正常方法是定义一个接口并使用此接口注册一个实现.现在,我对视图有疑问.场景很简单:
假设允许设置播放命令的自定义视频控件.该控件由简单的接口"IPlayControlView"定义.显而易见的问题是,当我解决此控件并尝试将其添加到a时StackPanel
,它不起作用,因为我有一个IPlayControl
,而不是一个UIElement
.
我可以投它UIElement
,因为我知道它是一个UIElement
.但有没有更好的方法,比如
public interface IPlayControlView : UIElement
Run Code Online (Sandbox Code Playgroud)
这不起作用,但也许其他一些事情会起作用......
这是一个普遍的问题,如果我使用接口解析视图,我每次都会遇到这个问题.也许它不是它的方式,但我一直认为其中一个....好吧,只是有个主意.我将只使用一个属性UIElement扩展IPlayControl,并将其设置为对自身的引用.所以,没关系,问题在打字时回答:-)
如果有更好的方法,我总是喜欢学习新事物.也许是IUIElement?
克里斯
我对下面的标记有两个问题:
<Popup>
<Button x:Name="button"/>
</Popup>
Run Code Online (Sandbox Code Playgroud)
VisualTreeHelper.GetParent(button)
返回null?Popup
的UIElement
?我完成了所有工作,但是当我点击设置时,设置窗口(在nswindowcontroller中)会在我的mac上运行的其他应用程序的后面打开.我希望它在前面,以便用户在点击它时可以看到它.
谢谢你们!
我试图将属性设置UIElement
为不可聚焦,但似乎没有按钮的isfocusable属性.有没有人有什么建议?谢谢 :)
我在创建散点图的屏幕截图时遇到问题.我的屏幕截图始终包含黑框.
这是我的XAML代码:
<s:SurfaceWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.microsoft.com/surface/2008"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="MakeScreenshots.SurfaceWindow1"
Title="MakeScreenshots" Width="1000" Height="700"
>
<s:SurfaceWindow.Resources>
<ImageBrush x:Key="WindowBackground" Stretch="None" Opacity="0.6" ImageSource="pack://application:,,,/Resources/WindowBackground.jpg"/>
</s:SurfaceWindow.Resources>
<Grid x:Name="GlobalGrid" Background="{StaticResource WindowBackground}" Width="1000" Height="700" >
<s:ScatterView x:Name="ScatterViewScreenShot" Margin="108,89,176,73" Width="700" Height="500">
<s:ScatterView.Background>
<SolidColorBrush Color="{DynamicResource {x:Static SystemColors.ActiveCaptionColorKey}}"/>
</s:ScatterView.Background>
<s:ScatterViewItem Margin="0,-26.953,-130.946,-23.047" Content="ScatterViewItem 3" HorizontalAlignment="Right" Width="125.826"/>
<s:ScatterViewItem Margin="0,0,-490.513,-151.256" HorizontalAlignment="Right" Width="125.77" Height="60.427" VerticalAlignment="Bottom" Content="ScatterViewItem 2"/>
<s:ScatterViewItem Content="ScatterViewItem 1" Margin="-331.43,0,0,-129.589" HorizontalAlignment="Left" Width="177.949" Height="67.905" VerticalAlignment="Bottom"/>
</s:ScatterView>
<Button x:Name="MakeScreenShotButton" Click="MakeScreenShotButton_Click" Content="MakeScreenShot" Margin="267,17,343,0" VerticalAlignment="Top" Height="38.96"/>
<Button Content="MakeScreenShotButton2" Height="39" HorizontalAlignment="Left" Margin="116,614,0,0" Name="button1" VerticalAlignment="Top" Width="301" Click="MakeScreenShotButton2_Click" />
<Button …
Run Code Online (Sandbox Code Playgroud) 我想把WPF WebBrowser放一些UIElement
(opacity = 0)ie并通过这个覆盖所有点击事件UIElement
.
有可能吗?
这段代码不起作用......
<Canvas Name="cnsMain">
<WebBrowser x:Name="MainBrowser" Visibility="Visible" Panel.ZIndex="0" />
<Canvas Panel.ZIndex="100" Opacity="0.01"></Canvas>
</Canvas>
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在尝试找到一种在UIElement上设置Background属性的通用方法.
我运气不好......
这是我到目前为止(尝试使用反射来获取BackgroundProperty).
Action<UIElement> setTheBrushMethod = (UIElement x) =>
{
var brush = new SolidColorBrush(Colors.Yellow);
var whatever = x.GetType().GetField("BackgroundProperty");
var val = whatever.GetValue(null);
((UIElement)x).SetValue(val as DependencyProperty, brush);
brush.BeginAnimation(SolidColorBrush.ColorProperty, new ColorAnimation(Colors.White, TimeSpan.FromSeconds(3)));
};
setTheBrushMethod(sender as UIElement);
Run Code Online (Sandbox Code Playgroud)
事情是......它适用于类似TextBlock的东西,但不适用于像StackPanel或Button这样的东西.
对于StackPanel或Button,"whatever"最终为null.
我也觉得应该有一个简单的方法来一般设置背景.我错过了吗?
后台似乎只在System.Windows.Controls.Control上可用,但我无法转换为.
在C#中PropertyInspectorView
是Type UIElement
.
我需要得到孩子们PropertyInspectorView
.没有继承方法可以做到这一点.既然继承了,UIElement
我想知道是否有办法让UIElement
孩子.
感谢您的关注.这个问题不是已经提出的问题的重复.已经问过的问题有一个xaml部分.我的问题是关于没有XAML连接和purley C#的代码.请尽可能删除重复的标签.谢谢-
我需要隐藏我的 javafx 应用程序的停靠栏图标。在普通的 Java 应用程序中,这可以通过以下属性实现:
System.setProperty("apple.awt.UIElement", "true");
但是,这似乎不适用于 JavaFX。
谢谢!
是否有任何情况下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) 由于UIElement
没有财产DataContext
,我怎么能得到DataContext
的UIElement
?
我花了20分钟试图在C#中找到一个如何在两个矩形之间画一条线的例子,我找不到任何东西.我不知道我是不是不理解在Silverlight中绘制2D形状的范例,或者我只是在寻找错误的地方.
我已经设置了矩形,所以我可以拖动它们,现在我想在画布上拖动一个矩形时在两个形状之间画一条线.当我拖动第二个矩形时,我希望能够做到这样的事情:
void host1_MouseLeftButtonMove(object sender, MouseEventArgs e)
{
if (isDown)
{
this.host1TranslateTransform.X = e.GetPosition(canvas).X - x;
this.host1TranslateTransform.Y = e.GetPosition(canvas).Y - y;
Line l = new Line();
l.X1 = rect1.X; // does not work
l.X2 = e.GetPosition(canvas).X;
l.Y1 = rect1.Y; // does not work
l.Y2 = e.GetPosition(canvas).Y;
}
}
Run Code Online (Sandbox Code Playgroud)
如何获取第一个框的坐标?我无法弄清楚如何在我的应用程序中获取相对于画布的形状坐标.我将非常感谢任何有关如何绘制简单2D形状的初学者概述的教程.
谢谢!