OK, solved that error. Namespace troubles....
Now my new control is completly without errors.... only problem is, it doesn't show up on my window. I'll post the complete code.
AssemblyInfo.vb (added line only)
Code:
<Assembly: Windows.ThemeInfo(Windows.ResourceDictionaryLocation.None, Windows.ResourceDictionaryLocation.SourceAssembly)>
Generic.xaml
Code:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:WPFControls">
<Style TargetType="{x:Type Controls:ScrollViewerThumbnail}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:ScrollViewerThumbnail}">
<Viewbox DataContext="{TemplateBinding ScrollViewer}" Stretch="Uniform">
<Grid>
<Rectangle Width="{Binding Content.ActualWidth}" Height="{Binding Content.ActualHeight}">
<Rectangle.Fill>
<VisualBrush Visual="{Binding Content}" />
</Rectangle.Fill>
</Rectangle>
<Thumb Name="ThumbHighlight" Background="{TemplateBinding HighlightFill}" Width="{Binding ViewportWidth}"
Height="{Binding ViewportHeight}" HorizontalAlignment="Left" VerticalAlignment="Top">
<Thumb.RenderTransform>
<TranslateTransform X="{Binding HorizontalOffset}" Y="{Binding VerticalOffset}" />
</Thumb.RenderTransform>
<Thumb.Template>
<ControlTemplate TargetType="Thumb">
<Border Background="{TemplateBinding Background}" />
</ControlTemplate>
</Thumb.Template>
</Thumb>
</Grid>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
ScrollViewerThumbnail.xaml.vb
Code:
Imports System.Windows.Media
Partial Public Class ScrollViewerThumbnail
Inherits Windows.Controls.Control
Public Sub New()
DefaultStyleKeyProperty.OverrideMetadata(GetType(ScrollViewerThumbnail), New Windows.FrameworkPropertyMetadata(GetType(ScrollViewerThumbnail)))
End Sub
Public Property ScrollViewer() As Windows.Controls.ScrollViewer
Get
Return DirectCast(GetValue(ScrollViewerProperty), Windows.Controls.ScrollViewer)
End Get
Set(ByVal value As Windows.Controls.ScrollViewer)
SetValue(ScrollViewerProperty, value)
End Set
End Property
Public Property HighlightFill() As Brush
Get
Return DirectCast(GetValue(HighlightFillProperty), Brush)
End Get
Set(ByVal value As Brush)
SetValue(HighlightFillProperty, value)
End Set
End Property
Public Shared ReadOnly ScrollViewerProperty As Windows.DependencyProperty = Windows.DependencyProperty.Register("ScrollViewer", GetType(ScrollViewerThumbnail), GetType(ScrollViewerThumbnail), New Windows.UIPropertyMetadata(Nothing))
Public Shared ReadOnly HighlightFillProperty As Windows.DependencyProperty = Windows.DependencyProperty.Register("HighlightFill", GetType(Brush), GetType(ScrollViewerThumbnail), New Windows.UIPropertyMetadata(New SolidColorBrush(Color.FromArgb(128, 255, 255, 0))))
Private Const ThumbName As String = "ThumbHighlight"
Public Overrides Sub OnApplyTemplate()
MyBase.OnApplyTemplate()
Dim PartHighlight As Windows.Controls.Primitives.Thumb
PartHighlight = DirectCast(Me.Template.FindName(ThumbName, Me), Windows.Controls.Primitives.Thumb)
AddHandler PartHighlight.DragDelta, AddressOf PartHighlight_DragDelta
End Sub
Private Sub PartHighlight_DragDelta(ByVal sender As Object, ByVal e As Windows.Controls.Primitives.DragDeltaEventArgs)
ScrollViewer.ScrollToVerticalOffset(ScrollViewer.VerticalOffset + e.VerticalChange)
ScrollViewer.ScrollToHorizontalOffset(ScrollViewer.HorizontalOffset + e.HorizontalChange)
End Sub
End Class
VUI_Main.xaml (using the control)
Code:
<Window x:Class="VUI_Main"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:WPFControls;assembly=WPFControls"
Title="Victory! User Interface" Width="1280" Height="1024">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="360" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="206" />
</Grid.RowDefinitions>
<TabControl Name="MenuPanel" Grid.Row="0" Grid.Column="0">
<TabItem Name="EconomyPanel" Header="Economy" />
<TabItem Name="MilitaryPanel" Header="Military" />
<TabItem Name="PoliticalPanel" Header="Political" />
</TabControl>
<ScrollViewer x:Name="MapScroller" HorizontalScrollBarVisibility="Visible" Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" HorizontalAlignment="Left" VerticalAlignment="Top">
<Canvas Name="MapCanvas" Width="8980" Height="5160">
<Canvas.Background>
<ImageBrush ImageSource="/Resources/MainMap.jpg" ScrollViewer.CanContentScroll="True"/>
</Canvas.Background>
</Canvas>
</ScrollViewer>
<Controls:ScrollViewerThumbnail ScrollViewer="{Binding ElementName=MapScroller}" Grid.Row="1" Grid.Column="0" />
</Grid>
</Window>
Just a reminder: I'm trying to build this (and the 2 articles it builds on) in VB.