0

I got this sample code from this forum.

<DatePicker SelectedDate="{Binding MainReportEndDate, Mode=TwoWay}"
                            DataContext="{Binding DataContext, RelativeSource= {RelativeSource FindAncestor, AncestorType={x:Type GroupBox}}}" 
                            
                            DisplayDateStart="1/01/20" DisplayDateEnd="12/31/22"
                            FirstDayOfWeek="Monday"">
        <DatePicker.Resources>
            <Style TargetType="{x:Type DatePickerTextBox}">
                <Setter Property="Control.Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <TextBox x:Name="PART_TextBox"
                                     Text="{Binding Path=SelectedDate, 
                                            RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}, 
                                            StringFormat={}{0:MMM yy}}" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </DatePicker.Resources>
    </DatePicker>

But it doesn't work. I want the same result as the one in the picture "Jul 20"

enter image description here

1

1 Answer 1

0

Try this

<TextBox x:Name="PART_TextBox"
     Text="{Binding Path=SelectedDate, StringFormat='dd MMM yyyy', 
     RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.