diff options
author | Bertrand Le Roy <beleroy@microsoft.com> | 2018-06-02 05:24:18 +0300 |
---|---|---|
committer | Bertrand Le Roy <beleroy@microsoft.com> | 2018-06-02 05:24:18 +0300 |
commit | 3ee26ce9dbc1a1c021ca7b23b2e555fbdd061e7c (patch) | |
tree | 982e4e9acb16f1734eceb660a91f5753fdf09aa3 | |
parent | a8058aa951bb31c3307c41c0d470b3a29e5783e4 (diff) |
Setup proxy resources so bindings have a lower probability to fail to find their sourcebleroy-fix-md-binding-errors
-rw-r--r-- | Xamarin.PropertyEditing.Windows/Themes/Resources.xaml | 10 | ||||
-rw-r--r-- | Xamarin.PropertyEditing/ViewModels/BrushPropertyViewModel.cs | 10 |
2 files changed, 12 insertions, 8 deletions
diff --git a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml index 5f40012..c6c78d6 100644 --- a/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml +++ b/Xamarin.PropertyEditing.Windows/Themes/Resources.xaml @@ -1297,6 +1297,9 @@ Grid.Column="0" Grid.Row="0" Panel.ZIndex="0" BorderThickness="0" ItemsSource="{Binding NormalColorScale}" SelectedValue="{Binding NormalColor}" SelectedValuePath=""> + <local:ChoiceControl.Resources> + <FrameworkElement x:Key="NormalColorProxyElement" DataContext="{Binding}"/> + </local:ChoiceControl.Resources> <local:ChoiceControl.ItemTemplate> <DataTemplate> <RadioButton Style="{DynamicResource MaterialDesignColorControlItem}" @@ -1304,7 +1307,7 @@ ToolTip="{Binding Label}" AutomationProperties.Name="{Binding Label}" AutomationProperties.HelpText="{Binding Label}" GroupName="MaterialDesignAccentOrNormal"> <local:BrushBoxControl Label="{Binding Label}" FontSize="10" - LightForegroundThreshold="{Binding Path=DataContext.NormalColorScriptureLightnessThreshold, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ChoiceControl}}}"> + LightForegroundThreshold="{Binding Path=DataContext.NormalColorScriptureLightnessThreshold, Source={StaticResource NormalColorProxyElement}, Mode=OneTime}"> <local:BrushBoxControl.Brush> <SolidColorBrush Color="{Binding Converter={local:CommonColorToColorConverter}}"/> </local:BrushBoxControl.Brush> @@ -1325,6 +1328,9 @@ Grid.Column="0" Grid.Row="0" Panel.ZIndex="0" BorderThickness="0" ItemsSource="{Binding AccentColorScale}" SelectedValue="{Binding AccentColor}" SelectedValuePath=""> + <local:ChoiceControl.Resources> + <FrameworkElement x:Key="AccentColorProxyElement" DataContext="{Binding}"/> + </local:ChoiceControl.Resources> <local:ChoiceControl.ItemTemplate> <DataTemplate> <RadioButton Style="{DynamicResource MaterialDesignColorControlItem}" @@ -1332,7 +1338,7 @@ ToolTip="{Binding Label}" AutomationProperties.Name="{Binding Label}" AutomationProperties.HelpText="{Binding Label}" GroupName="MaterialDesignAccentOrNormal"> <local:BrushBoxControl Label="{Binding Label}" FontSize="10" - LightForegroundThreshold="{Binding Path=DataContext.AccentColorScriptureLightnessThreshold, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ChoiceControl}}}"> + LightForegroundThreshold="{Binding Path=DataContext.AccentColorScriptureLightnessThreshold, Source={StaticResource AccentColorProxyElement}, Mode=OneTime}"> <local:BrushBoxControl.Brush> <SolidColorBrush Color="{Binding Converter={local:CommonColorToColorConverter}}"/> </local:BrushBoxControl.Brush> diff --git a/Xamarin.PropertyEditing/ViewModels/BrushPropertyViewModel.cs b/Xamarin.PropertyEditing/ViewModels/BrushPropertyViewModel.cs index 7ca8762..4c91c66 100644 --- a/Xamarin.PropertyEditing/ViewModels/BrushPropertyViewModel.cs +++ b/Xamarin.PropertyEditing/ViewModels/BrushPropertyViewModel.cs @@ -15,12 +15,10 @@ namespace Xamarin.PropertyEditing.ViewModels public BrushPropertyViewModel (TargetPlatform platform, IPropertyInfo property, IEnumerable<IObjectEditor> editors) : base (platform, property, editors) { - if (property.Type.IsAssignableFrom (typeof (CommonSolidBrush))) { - Solid = new SolidBrushViewModel (this, - property is IColorSpaced colorSpacedPropertyInfo ? colorSpacedPropertyInfo.ColorSpaces : null); - if (platform.SupportsMaterialDesign) { - MaterialDesign = new MaterialDesignColorViewModel (this); - } + Solid = new SolidBrushViewModel (this, + property is IColorSpaced colorSpacedPropertyInfo ? colorSpacedPropertyInfo.ColorSpaces : null); + if (platform.SupportsMaterialDesign) { + MaterialDesign = new MaterialDesignColorViewModel (this); } // TODO: we actually need to localize this for platforms really, "brush" doesn't make sense for some |