Change Width of Calendar to the width of its parent DatePicker using Style
<p>I have a WPF style for DatePicker inside which the Calendar of DatePicker is also styled. Take a look at it below:</p>

<pre><code>&lt;Style TargetType="{x:Type DatePicker}" x:Key="datePickerGeneralStyle" BasedOn="{StaticResource {x:Type DatePicker}}"&gt;
    &lt;Setter Property="TextElement.FontSize" Value="{StaticResource 24}" /&gt;
    &lt;Setter Property="VerticalAlignment" Value="{StaticResource Center}" /&gt;
    &lt;Setter Property="VerticalContentAlignment" Value="{StaticResource Center}" /&gt;
    &lt;Setter Property="DatePicker.CalendarStyle"&gt;
        &lt;Setter.Value&gt;
            &lt;Style TargetType="{x:Type Calendar}"&gt;
                &lt;Setter Property="Template"&gt;
                    &lt;Setter.Value&gt;
                        &lt;ControlTemplate TargetType="{x:Type Calendar}"&gt;
                            &lt;Viewbox Height="{Binding DatePicker.Width}" Width="{Binding DatePicker.Width}"&gt;
                                &lt;CalendarItem x:Name="PART_CalendarItem"
                              Background="{TemplateBinding Background}"
                              BorderBrush="{TemplateBinding BorderBrush}"
                              BorderThickness="{TemplateBinding BorderThickness}"/&gt;
                            &lt;/Viewbox&gt;
                        &lt;/ControlTemplate&gt;
                    &lt;/Setter.Value&gt;
                &lt;/Setter&gt;
            &lt;/Style&gt;
        &lt;/Setter.Value&gt;
    &lt;/Setter&gt;
&lt;/Style&gt;
</code></pre>

<p>Now looking at below line in above code:</p>

<pre><code>&lt;Viewbox Height="{Binding DatePicker.Width}" Width="{Binding DatePicker.Width}"&gt;
</code></pre>

<p>Now I want to make this style generic. So, when I declare a DatePicker and set its style property to datePickerGeneralStyle, the Calendar of DatePicker should get same Width as Datepicker's width. I want this Behaviour even if Date Picker's Width is not mentioned, I mean DatePicker should use the available space in container or what we call Auto Width.</p>