Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 0cd7005

Browse files
committed
Merge pull request #67 from github/shana/62-fix-checkbox
Checkbox styling fix for #62
2 parents f615190 + 3f70f80 commit 0cd7005

File tree

3 files changed

+27
-47
lines changed

3 files changed

+27
-47
lines changed

src/GitHub.VisualStudio/SharedDictionary.xaml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,14 @@
1010

1111
<Style x:Key="VSStyledButton" TargetType="{x:Type Button}" BasedOn="{StaticResource VsButtonStyleKey}">
1212
</Style>
13-
<Style x:Key="VSStyledCheckBox" TargetType="{x:Type CheckBox}">
14-
<Setter Property="Control.Template">
15-
<Setter.Value>
16-
<ControlTemplate TargetType="{x:Type CheckBox}">
17-
<CheckBox Foreground="{DynamicResource VsBrush.ToolWindowText}" Background="{DynamicResource VsBrush.ToolWindowBackground}">
18-
<TextBlock TextWrapping="Wrap" Foreground="{DynamicResource VsBrush.ToolWindowText}" Background="{DynamicResource VsBrush.ToolWindowBackground}">
19-
<TextBlock.Inlines>
20-
<Run Text="{TemplateBinding Content}" />
21-
</TextBlock.Inlines>
22-
</TextBlock>
23-
</CheckBox>
24-
<ControlTemplate.Triggers>
25-
<Trigger Property="UIElement.IsMouseOver" Value="true">
26-
<Setter Property="Background" Value="{DynamicResource VsBrush.ToolWindowBackground}"/>
27-
</Trigger>
28-
</ControlTemplate.Triggers>
29-
</ControlTemplate>
30-
</Setter.Value>
31-
</Setter>
13+
<Style x:Key="VSStyledCheckBox" BasedOn="{StaticResource VsCheckBoxStyleKey}" TargetType="{x:Type CheckBox}">
14+
<Setter Property="Foreground" Value="{DynamicResource VsBrush.ToolWindowText}" />
15+
<Setter Property="Background" Value="{DynamicResource VsBrush.ToolWindowBackground}" />
16+
<Style.Triggers>
17+
<Trigger Property="UIElement.IsMouseOver" Value="true">
18+
<Setter Property="Background" Value="{DynamicResource VsBrush.ToolWindowBackground}"/>
19+
</Trigger>
20+
</Style.Triggers>
3221
</Style>
3322
<Style x:Key="VSStyledComboBox" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource VsComboBoxStyleKey}">
3423
</Style>

src/GitHub.VisualStudio/UI/Views/Controls/RepositoryPublishControl.xaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,24 @@
123123

124124
<CheckBox x:Name="makePrivate"
125125
Margin="0,8,0,0"
126-
Style="{StaticResource VSStyledCheckBox}">Private Repository</CheckBox>
126+
Style="{StaticResource VSStyledCheckBox}">
127+
<TextBlock TextWrapping="Wrap"
128+
Foreground="{DynamicResource VsBrush.ToolWindowText}"
129+
Background="{DynamicResource VsBrush.ToolWindowBackground}">
130+
<TextBlock.Resources>
131+
<Style TargetType="{x:Type TextBlock}">
132+
<Style.Triggers>
133+
<Trigger Property="IsEnabled" Value="False">
134+
<Setter Property="Opacity" Value="0.5" />
135+
</Trigger>
136+
</Style.Triggers>
137+
</Style>
138+
</TextBlock.Resources>
139+
<TextBlock.Inlines>
140+
<Run>Private Repository</Run>
141+
</TextBlock.Inlines>
142+
</TextBlock>
143+
</CheckBox>
127144

128145
<Label x:Name="upgradeToMicroPlanWarning" HorizontalAlignment="Left" Visibility="Collapsed">
129146
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">

src/GitHub.VisualStudio/UI/Views/Controls/RepositoryPublishControl.xaml.cs

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,7 @@ public RepositoryPublishControl()
3030
d(this.Bind(ViewModel, vm => vm.RepositoryName, v => v.nameText.Text));
3131

3232
d(this.Bind(ViewModel, vm => vm.Description, v => v.description.Text));
33-
34-
d(this.WhenAnyValue(x => x.ViewModel.KeepPrivate)
35-
.Subscribe(keepPrivate =>
36-
{
37-
// because we removed this.Bind, set this by hand
38-
if (keepPrivate != makePrivate.IsChecked)
39-
{
40-
makePrivate.IsChecked = keepPrivate;
41-
}
42-
}));
43-
44-
// BEGIN DANGER ZONE
45-
//
46-
// This replaces the default Bind behaviour as the Checkbox control
47-
// does not raise an event here when it is hosted in the Team Explorer
48-
// view.
49-
//
50-
// We've used this.Bind in other places (popups) so it's something
51-
// we need to investigate further
52-
//
53-
d(Observable.FromEventPattern<RoutedEventArgs>(makePrivate, "Checked")
54-
.Subscribe(_ => ViewModel.KeepPrivate = true));
55-
d(Observable.FromEventPattern<RoutedEventArgs>(makePrivate, "Unchecked")
56-
.Subscribe(_ => ViewModel.KeepPrivate = false));
57-
// END DANGER ZONE
58-
59-
33+
d(this.Bind(ViewModel, vm => vm.KeepPrivate, v => v.makePrivate.IsChecked));
6034
d(this.OneWayBind(ViewModel, vm => vm.CanKeepPrivate, v => v.makePrivate.IsEnabled));
6135

6236
//d(this.OneWayBind(ViewModel, vm => vm.ShowUpgradeToMicroPlanWarning, v => v.upgradeToMicroPlanWarning.Visibility));

0 commit comments

Comments
 (0)