Daniel Capek
Daniel Capek

Reputation: 141

Xceed DateTimePicker, isEnabled time picker

I using xceed components in our project. Now what I need to do is readOnly property for timePicker. Currently I got this:

<DockPanel LastChildFill="True" Width="Auto" MinWidth="140" Height="25" Margin="2">
     <TextBlock Text="Od " TextAlignment="Right" VerticalAlignment="Center" FontSize="15"/>
     <xceed:DateTimePicker Format="Custom" 
                           FormatString="{Binding Path=CustomDateTimeFormat, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"  
                           FontSize="15" Value="{Binding Path=FromDate, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">

     </xceed:DateTimePicker>
 </DockPanel>

But I want timePicker from this DateTimePicker readOnly = true or false, depend on conditions. Im using MVVM pattern.

Upvotes: 0

Views: 199

Answers (1)

SamTh3D3v
SamTh3D3v

Reputation: 9944

Set a DataTrigger that changes the IsReadOnly property based on some property in the VM:

<xctk:DateTimePicker 
            FontSize="15" Value="{Binding Path=FromDate, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
            <xctk:DateTimePicker.Style>
                <Style TargetType="xctk:DateTimePicker">
                    <Setter Property="IsReadOnly" Value="False"/>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding SomeProperty}" Value="True">
                            <Setter Property="IsReadOnly" Value="SomeValue"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </xctk:DateTimePicker.Style>

        </xctk:DateTimePicker>

Upvotes: 2

Related Questions