Hello All,
I would first like to thank Martin again, he's sample got me pretty far. In fact in the first sample included below, I got my Labels and the slider bar behaving as I would like. When I tried porting over to my main application (the second sample below Sample2), I got some BUT not all behavior... Namely, the trackbar is not coloring correctly, nor does it have the proper thumbs, for the selector. I see in Martin's sample code that there is an application resource defined in the app.xaml file.
<
Application
x:Class
=
"BaseApplicationProject.App"
xmlns
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
=
"http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri
=
"MainWindow.xaml"
>
<
Application.Resources
>
<
ControlTemplate
x:Key
=
"largeDecreaseButtonTemplate"
TargetType
=
"{x:Type RepeatButton}"
>
<
Grid
Background
=
"{TemplateBinding Background}"
/>
</
ControlTemplate
>
</
Application.Resources
>
</
Application
>
However, my lack of familiarity with this has caused some problems. You see in my main app the App.xaml file has a ResourceDictionary defined:
<
Application
x:Class
=
"Worms.App"
xmlns
=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
=
"http://schemas.microsoft.com/winfx/2006/xaml"
Startup
=
"OnStartup"
Exit
=
"OnExit"
>
<
Application.Resources
>
<
ResourceDictionary
>
<
ResourceDictionary.MergedDictionaries
>
<
ResourceDictionary
Source
=
"/Fluent;Component/Themes/Generic.xaml"
/> <
ResourceDictionary
Source
=
"/Fluent;Component/Themes/Office2010/Silver.xaml"
/> <
ResourceDictionary
Source
=
"Theme/Colors/Silver.xaml"
/> <
ResourceDictionary
Source
=
"Theme/Theme.xaml"
/> <
ResourceDictionary
Source
=
"Theme/Resources.xaml"
/> <
ResourceDictionary
Source
=
"pack://application:,,,/AvalonDock.Themes;component/themes/dev2010.xaml"
/> <
ResourceDictionary
Source
=
"Theme/AvalonDockTheme.xaml"
/>
</
ResourceDictionary.MergedDictionaries
>
</
ResourceDictionary
>
</
Application.Resources
>
</
Application
>
So, I tried to put the ControlTemplate in one of the included files of the ResourceDictionary, more precisely into either Theme/Theme.xaml or Theme/Resources.xaml. Neither one seemed to work. The problem I get is a Null reference in the SliderUtilities.cs file in the slider_Loaded function:
1.
static
void
slider_Loaded(
object
sender, RoutedEventArgs e)
2.
{
3.
var slider = (RadSlider)sender;
4.
var button = slider.ChildrenOfType<RepeatButton>().FirstOrDefault(x => x.Name ==
"LargeDecreaseButton"
);
5.
button.Template = (ControlTemplate)Application.Current.Resources[
"largeDecreaseButtonTemplate"
];
6.
7.
slider.Tag = button;
8.
}
When I step through this function in Martin's sample after line 4 is executed, button is instantiated to a good value. In my main app, when I step through the same function, button is null... Not Good! Also the slider variable in Martin's sample has an instantiated decreaseButton and increaseButton of type System.Windows.Controls.Primitives.RepeatButton. In my main app, they are both null....
Any ideas why the slider control/variable is NOT picking up the ControlTemplate for the repeatbuttons???
Thanks again in advance!,
Kevin Orcutt
Senior Software Engineer
Wurth Electronics ICS, Inc.
7496 Webster St., Dayton, OH 45414
Tel: 937.415.7700
Toll Free: 877.690.2207
Fax: 937.415.7710
Email: kevin.orcutt@we-ics.com
http://www.we-ics.com