Is it possible to hide a part of a WPF control? .NET 4 has a DatePicker which renders 4 parts, according to MSDN. Is it possible to hide (in my case) the TextBox part (probably named PART_TextBox)?
I have seen examples of styling the DatePicker completely, and it involves alot of XAML, when all I want to do is hide one part of the control.
Why not add
Visibility="Collapsed"
to the relevantTextBox
in the default style?Well, I have a solution for your case :)
You could change the default
Button
Style
to beVisibility.Collapsed
. For example, if you wanted to hide the Buttons for 2 DatePickers in a Grid you could do as follows:XAML only solution w/o inheritance ...
You can do it all in XAML with behaviors and the
TemplatePartAction
I wrote:and here is the
TemplatePart
functionality:If you are not familiar with behaviors, Install the Expression Blend 4 SDK and add these namespaces:
and add
System.Windows.Interactivity
andMicrosoft.Expression.Interactions
to your project.