Skip to content

Commit

Permalink
[MainDemo] Fix for DateTimePickerCulture binding
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Apr 9, 2019
1 parent 5996152 commit a1c0938
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@
Grid.Column="1"
VerticalAlignment="Center"
Controls:TextBoxHelper.ClearTextButton="True"
ItemsSource="{Binding CultureInfos, Mode=OneWay}">
ItemsSource="{Binding CultureInfos, Mode=OneWay}"
SelectedItem="{Binding CurrentCulture, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ComboBox.ItemTemplate>
<DataTemplate DataType="{x:Type globalization:CultureInfo}">
<StackPanel Orientation="Horizontal">
Expand All @@ -227,28 +228,21 @@
</ComboBox>
</Grid>
<Controls:DateTimePicker Controls:TextBoxHelper.UseFloatingWatermark="True"
Culture="{Binding CurrentCulture, Mode=OneWay}"
HandVisibility="{Binding Path=SelectedItem, ElementName=DateTimePickerHandVisibility, Mode=TwoWay}"
IsClockVisible="{Binding Path=IsChecked, ElementName=DateTimePickerIsClockVisible, Mode=TwoWay}"
IsEnabled="{Binding Path=IsChecked, ElementName=DateTimePickerIsEnabled, Mode=TwoWay}"
IsReadOnly="{Binding Path=IsChecked, ElementName=DateTimePickerIsReadOnly, Mode=TwoWay}"
Orientation="{Binding Path=SelectedItem, ElementName=DateTimePickerOrientation, Mode=TwoWay}"
PickerVisibility="{Binding Path=SelectedItem, ElementName=DateTimePickerPickerVisibility, Mode=TwoWay}"
SelectedDateFormat="{Binding Path=SelectedItem, ElementName=DateTimePickerDateFormat}"
SelectedTimeFormat="{Binding Path=SelectedItem, ElementName=DateTimePickerTimeFormat}">
<Controls:DateTimePicker.Culture>
<Binding ElementName="DateTimePickerCulture"
Path="SelectedItem">
<Binding.TargetNullValue>
{x:Static globalization:CultureInfo.CurrentCulture}
</Binding.TargetNullValue>
</Binding>
</Controls:DateTimePicker.Culture>
</Controls:DateTimePicker>
SelectedTimeFormat="{Binding Path=SelectedItem, ElementName=DateTimePickerTimeFormat}" />
<GroupBox Header="Current time">
<AdornerDecorator>
<StackPanel>
<Controls:DateTimePicker x:Name="DateTimePicker"
Margin="2"
Culture="{Binding CurrentCulture, Mode=OneWay}"
HandVisibility="{Binding Path=SelectedItem, ElementName=DateTimePickerHandVisibility, Mode=TwoWay}"
IsClockVisible="{Binding Path=IsChecked, ElementName=DateTimePickerIsClockVisible, Mode=TwoWay}"
IsEnabled="{Binding Path=IsChecked, ElementName=DateTimePickerIsEnabled, Mode=TwoWay}"
Expand All @@ -257,35 +251,19 @@
PickerVisibility="{Binding Path=SelectedItem, ElementName=DateTimePickerPickerVisibility, Mode=TwoWay}"
SelectedDateFormat="{Binding Path=SelectedItem, ElementName=DateTimePickerDateFormat}"
SelectedTimeFormat="{Binding Path=SelectedItem, ElementName=DateTimePickerTimeFormat}">
<Controls:DateTimePicker.Culture>
<Binding ElementName="DateTimePickerCulture"
Path="SelectedItem">
<Binding.TargetNullValue>
{x:Static globalization:CultureInfo.CurrentCulture}
</Binding.TargetNullValue>
</Binding>
</Controls:DateTimePicker.Culture>
<i:Interaction.Behaviors>
<behaviors:DateTimeNowBehavior />
</i:Interaction.Behaviors>
</Controls:DateTimePicker>

<Controls:TimePicker Margin="2"
Culture="{Binding CurrentCulture, Mode=OneWay}"
HandVisibility="{Binding Path=SelectedItem, ElementName=DateTimePickerHandVisibility, Mode=TwoWay}"
IsEnabled="{Binding Path=IsChecked, ElementName=DateTimePickerIsEnabled, Mode=TwoWay}"
IsReadOnly="{Binding Path=IsChecked, ElementName=DateTimePickerIsReadOnly, Mode=TwoWay}"
PickerVisibility="{Binding Path=SelectedItem, ElementName=DateTimePickerPickerVisibility, Mode=TwoWay}"
SelectedDateTime="{Binding Path=SelectedDateTime, ElementName=DateTimePicker}"
SelectedTimeFormat="{Binding Path=SelectedItem, ElementName=DateTimePickerTimeFormat}">
<Controls:TimePicker.Culture>
<Binding ElementName="DateTimePickerCulture"
Path="SelectedItem">
<Binding.TargetNullValue>
{x:Static globalization:CultureInfo.CurrentCulture}
</Binding.TargetNullValue>
</Binding>
</Controls:TimePicker.Culture>
</Controls:TimePicker>
SelectedTimeFormat="{Binding Path=SelectedItem, ElementName=DateTimePickerTimeFormat}" />

<Controls:TimePicker Margin="2"
Controls:TextBoxHelper.AutoWatermark="True"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,21 @@ public void Dispose()
public List<Artist> Artists { get; set; }
public List<AccentColorMenuData> AccentColors { get; set; }
public List<AppThemeMenuData> AppThemes { get; set; }

public List<CultureInfo> CultureInfos { get; set; }

private CultureInfo currentCulture = CultureInfo.CurrentCulture;
public CultureInfo CurrentCulture
{
get { return currentCulture; }
set
{
if (Equals(value, this.currentCulture)) return;
currentCulture = value;
RaisePropertyChanged("CurrentCulture");
}
}

private ICommand endOfScrollReachedCmdWithParameter;

public ICommand EndOfScrollReachedCmdWithParameter
Expand Down Expand Up @@ -166,7 +179,7 @@ public bool QuitConfirmationEnabled
get { return _quitConfirmationEnabled; }
set
{
if (value.Equals(_quitConfirmationEnabled)) return;
if (Equals(value, _quitConfirmationEnabled)) return;
_quitConfirmationEnabled = value;
RaisePropertyChanged("QuitConfirmationEnabled");
}
Expand All @@ -178,7 +191,7 @@ public bool ShowMyTitleBar
get { return showMyTitleBar; }
set
{
if (value.Equals(showMyTitleBar)) return;
if (Equals(value, showMyTitleBar)) return;
showMyTitleBar = value;
RaisePropertyChanged("ShowMyTitleBar");
}
Expand Down

0 comments on commit a1c0938

Please sign in to comment.