UWP - How to bind different SolidColorBrush through a Status?
up vote
1
down vote
favorite
public DateTime? ToDate { get; set; }
status is ToDate
, I added a property to model. logic looks like:
public SolidColorBrush ToDateForeground
{
get
{
if (ToDate.HasValue && ToDate.Value <= DateTime.Now)
{
return new SolidColorBrush(Colors.Red);
}
return Application.Current.Resources["SystemControlForegroundBaseLowBrush"];
}
}
Xaml
<TextBlock Foreground="{x:Bind ToDateForeground, Mode=OneWay}" Text="Test" />
It can work, however, if the user changes the Windows color to Dark, the ToDateForeground
doesn't automatically change.
How to deal with it, just like ThemeReource
?
xaml uwp
add a comment |
up vote
1
down vote
favorite
public DateTime? ToDate { get; set; }
status is ToDate
, I added a property to model. logic looks like:
public SolidColorBrush ToDateForeground
{
get
{
if (ToDate.HasValue && ToDate.Value <= DateTime.Now)
{
return new SolidColorBrush(Colors.Red);
}
return Application.Current.Resources["SystemControlForegroundBaseLowBrush"];
}
}
Xaml
<TextBlock Foreground="{x:Bind ToDateForeground, Mode=OneWay}" Text="Test" />
It can work, however, if the user changes the Windows color to Dark, the ToDateForeground
doesn't automatically change.
How to deal with it, just like ThemeReource
?
xaml uwp
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
public DateTime? ToDate { get; set; }
status is ToDate
, I added a property to model. logic looks like:
public SolidColorBrush ToDateForeground
{
get
{
if (ToDate.HasValue && ToDate.Value <= DateTime.Now)
{
return new SolidColorBrush(Colors.Red);
}
return Application.Current.Resources["SystemControlForegroundBaseLowBrush"];
}
}
Xaml
<TextBlock Foreground="{x:Bind ToDateForeground, Mode=OneWay}" Text="Test" />
It can work, however, if the user changes the Windows color to Dark, the ToDateForeground
doesn't automatically change.
How to deal with it, just like ThemeReource
?
xaml uwp
public DateTime? ToDate { get; set; }
status is ToDate
, I added a property to model. logic looks like:
public SolidColorBrush ToDateForeground
{
get
{
if (ToDate.HasValue && ToDate.Value <= DateTime.Now)
{
return new SolidColorBrush(Colors.Red);
}
return Application.Current.Resources["SystemControlForegroundBaseLowBrush"];
}
}
Xaml
<TextBlock Foreground="{x:Bind ToDateForeground, Mode=OneWay}" Text="Test" />
It can work, however, if the user changes the Windows color to Dark, the ToDateForeground
doesn't automatically change.
How to deal with it, just like ThemeReource
?
xaml uwp
xaml uwp
edited Nov 21 at 4:02
asked Nov 21 at 3:50
HeroWong
1068
1068
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Did you tried to handle Windows color changes for your App:
var uiSettings = new UISettings();
var color = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background);
if (color == Windows.UI.Colors.Black) // Dark Mode
{
this.RequestedTheme = ApplicationTheme.Dark;
}
else if (color == Windows.UI.Colors.White) //Light Mode
{
this.RequestedTheme = ApplicationTheme.Light;
}
if the user changes the Windows color to Dark, the ToDateForeground doesn't automatically change.
Change RequestedTheme
for your app then all theme resources will changes to match current theme colors. please take a look at ApplicationTheme
No need to switch app theme, the theme of the app should follow the system.x:Bind
won't follow changes of system. therefore, I must useForeground="{ThemeResource xxxx}"
, but value is dynamic :(
– HeroWong
Nov 21 at 5:54
If i understand correctly , you want to change toSystemControlForegroundBaseLowBrush
whenif statement
return false so its doesn't change (when user choose new Color Mode for Windows) because it already set. So you need to update app theme to update ThemeResource color values base on App theme.
– MKH
Nov 21 at 6:21
Whether a UWP app hasOnThemeChanged
event?
– HeroWong
Nov 21 at 6:27
Maybe this post help you
– MKH
Nov 21 at 6:46
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Did you tried to handle Windows color changes for your App:
var uiSettings = new UISettings();
var color = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background);
if (color == Windows.UI.Colors.Black) // Dark Mode
{
this.RequestedTheme = ApplicationTheme.Dark;
}
else if (color == Windows.UI.Colors.White) //Light Mode
{
this.RequestedTheme = ApplicationTheme.Light;
}
if the user changes the Windows color to Dark, the ToDateForeground doesn't automatically change.
Change RequestedTheme
for your app then all theme resources will changes to match current theme colors. please take a look at ApplicationTheme
No need to switch app theme, the theme of the app should follow the system.x:Bind
won't follow changes of system. therefore, I must useForeground="{ThemeResource xxxx}"
, but value is dynamic :(
– HeroWong
Nov 21 at 5:54
If i understand correctly , you want to change toSystemControlForegroundBaseLowBrush
whenif statement
return false so its doesn't change (when user choose new Color Mode for Windows) because it already set. So you need to update app theme to update ThemeResource color values base on App theme.
– MKH
Nov 21 at 6:21
Whether a UWP app hasOnThemeChanged
event?
– HeroWong
Nov 21 at 6:27
Maybe this post help you
– MKH
Nov 21 at 6:46
add a comment |
up vote
0
down vote
Did you tried to handle Windows color changes for your App:
var uiSettings = new UISettings();
var color = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background);
if (color == Windows.UI.Colors.Black) // Dark Mode
{
this.RequestedTheme = ApplicationTheme.Dark;
}
else if (color == Windows.UI.Colors.White) //Light Mode
{
this.RequestedTheme = ApplicationTheme.Light;
}
if the user changes the Windows color to Dark, the ToDateForeground doesn't automatically change.
Change RequestedTheme
for your app then all theme resources will changes to match current theme colors. please take a look at ApplicationTheme
No need to switch app theme, the theme of the app should follow the system.x:Bind
won't follow changes of system. therefore, I must useForeground="{ThemeResource xxxx}"
, but value is dynamic :(
– HeroWong
Nov 21 at 5:54
If i understand correctly , you want to change toSystemControlForegroundBaseLowBrush
whenif statement
return false so its doesn't change (when user choose new Color Mode for Windows) because it already set. So you need to update app theme to update ThemeResource color values base on App theme.
– MKH
Nov 21 at 6:21
Whether a UWP app hasOnThemeChanged
event?
– HeroWong
Nov 21 at 6:27
Maybe this post help you
– MKH
Nov 21 at 6:46
add a comment |
up vote
0
down vote
up vote
0
down vote
Did you tried to handle Windows color changes for your App:
var uiSettings = new UISettings();
var color = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background);
if (color == Windows.UI.Colors.Black) // Dark Mode
{
this.RequestedTheme = ApplicationTheme.Dark;
}
else if (color == Windows.UI.Colors.White) //Light Mode
{
this.RequestedTheme = ApplicationTheme.Light;
}
if the user changes the Windows color to Dark, the ToDateForeground doesn't automatically change.
Change RequestedTheme
for your app then all theme resources will changes to match current theme colors. please take a look at ApplicationTheme
Did you tried to handle Windows color changes for your App:
var uiSettings = new UISettings();
var color = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background);
if (color == Windows.UI.Colors.Black) // Dark Mode
{
this.RequestedTheme = ApplicationTheme.Dark;
}
else if (color == Windows.UI.Colors.White) //Light Mode
{
this.RequestedTheme = ApplicationTheme.Light;
}
if the user changes the Windows color to Dark, the ToDateForeground doesn't automatically change.
Change RequestedTheme
for your app then all theme resources will changes to match current theme colors. please take a look at ApplicationTheme
edited Nov 21 at 4:56
answered Nov 21 at 4:51
MKH
538
538
No need to switch app theme, the theme of the app should follow the system.x:Bind
won't follow changes of system. therefore, I must useForeground="{ThemeResource xxxx}"
, but value is dynamic :(
– HeroWong
Nov 21 at 5:54
If i understand correctly , you want to change toSystemControlForegroundBaseLowBrush
whenif statement
return false so its doesn't change (when user choose new Color Mode for Windows) because it already set. So you need to update app theme to update ThemeResource color values base on App theme.
– MKH
Nov 21 at 6:21
Whether a UWP app hasOnThemeChanged
event?
– HeroWong
Nov 21 at 6:27
Maybe this post help you
– MKH
Nov 21 at 6:46
add a comment |
No need to switch app theme, the theme of the app should follow the system.x:Bind
won't follow changes of system. therefore, I must useForeground="{ThemeResource xxxx}"
, but value is dynamic :(
– HeroWong
Nov 21 at 5:54
If i understand correctly , you want to change toSystemControlForegroundBaseLowBrush
whenif statement
return false so its doesn't change (when user choose new Color Mode for Windows) because it already set. So you need to update app theme to update ThemeResource color values base on App theme.
– MKH
Nov 21 at 6:21
Whether a UWP app hasOnThemeChanged
event?
– HeroWong
Nov 21 at 6:27
Maybe this post help you
– MKH
Nov 21 at 6:46
No need to switch app theme, the theme of the app should follow the system.
x:Bind
won't follow changes of system. therefore, I must use Foreground="{ThemeResource xxxx}"
, but value is dynamic :(– HeroWong
Nov 21 at 5:54
No need to switch app theme, the theme of the app should follow the system.
x:Bind
won't follow changes of system. therefore, I must use Foreground="{ThemeResource xxxx}"
, but value is dynamic :(– HeroWong
Nov 21 at 5:54
If i understand correctly , you want to change to
SystemControlForegroundBaseLowBrush
when if statement
return false so its doesn't change (when user choose new Color Mode for Windows) because it already set. So you need to update app theme to update ThemeResource color values base on App theme.– MKH
Nov 21 at 6:21
If i understand correctly , you want to change to
SystemControlForegroundBaseLowBrush
when if statement
return false so its doesn't change (when user choose new Color Mode for Windows) because it already set. So you need to update app theme to update ThemeResource color values base on App theme.– MKH
Nov 21 at 6:21
Whether a UWP app has
OnThemeChanged
event?– HeroWong
Nov 21 at 6:27
Whether a UWP app has
OnThemeChanged
event?– HeroWong
Nov 21 at 6:27
Maybe this post help you
– MKH
Nov 21 at 6:46
Maybe this post help you
– MKH
Nov 21 at 6:46
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405009%2fuwp-how-to-bind-different-solidcolorbrush-through-a-status%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown