您好我正在尝试在WPF窗口中实现用户定义的类?
奇怪的是,我已经这样做了,但这次它不起作用,我找不到我的错误......
这是班级:
Namespace Controls
Public Class WorkingPopup
Inherits Primitives.Popup
Public ReadOnly WorkingLabelProperty As DependencyProperty = DependencyProperty.Register("WorkingLabel", GetType(Label), GetType(WorkingPopup))
Public ReadOnly WorkingProgressBarProperty As DependencyProperty = DependencyProperty.Register("WorkingProgressBar", GetType(ProgressBar), GetType(WorkingPopup))
Private Property WorkingLabel As Label
Get
Return GetValue(WorkingLabelProperty)
End Get
Set(value As Label)
SetValue(WorkingLabelProperty, value)
End Set
End Property
Private Property WorkingProgressBar As ProgressBar
Get
Return GetValue(WorkingProgressBarProperty)
End Get
Set(value As ProgressBar)
SetValue(WorkingProgressBarProperty, value)
End Set
End Property
Public Sub New()
MyBase.New()
Placement = Primitives.PlacementMode.Center
StaysOpen = True
PopupAnimation = Primitives.PopupAnimation.Fade
WorkingLabel = New Label With {.Visibility = Windows.Visibility.Visible, .Content = "Working", .ContentStringFormat = "{0} ..."}
WorkingProgressBar = New ProgressBar With {.Height = 20, .Width = 200, .Margin = New Thickness(5)}
Child = New Border
With DirectCast(Child, Border)
.BorderBrush = SystemColors.ActiveBorderBrush
.Background = SystemColors.ControlLightLightBrush
.BorderThickness = New Thickness(1)
.Child = New StackPanel
With DirectCast(.Child, StackPanel)
.Children.Add(WorkingLabel)
.Children.Add(WorkingProgressBar)
End With
End With
End Sub
'Some more irrelevant code
End Class
End Namespace
这是我的XAML:
<RibbonWindow x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrl="clr-namespace:WpfApplication3.Controls"
Title="MainWindow" Height="600" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="CanResizeWithGrip">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.Children>
<ctrl:WorkingPopup/>
</Grid.Children>
</Grid>
</RibbonWindow>
也许是因为它的星期一早上......但我没有得到它......
由于
答案 0 :(得分:0)
将WorkingPopup的名称空间从Controls更改为WpfApplication3