Friday 15 August 2014

c# - WPF Bool DataTrigger - Change Font Colour -


I want to change the font color of many items on a WPF page based on the user-selected theme. (A light subject, and a deep subject)

I am using a database template to customize the contents of the list of contents, when the subject is dark, then I will use all the textblocks of the font colors as white I want to change in

In my previous class I am setting the dark theme as truth.

I have successfully set triggers down, although I

So, I textblocks to white Can the font color style give if DarkTheme = true

code:?

  Public Partial Media Media: UserControl {public bool darkTheme {get; Set; } Readonly DatabaseAsset _dbAssets = new DatabaseAsset (); Public Media () {InitializeComponent (); RefreshMediaList (); Darkthim = Global. Configuration. DarkModeAppleldEtheme (); }}   

XML:

  & lt; UserControl.Resources & gt; & Lt; Db: MediaAsset x: Key = "MediaAsset" /> & Lt; DataTemplate x: key = "MediaAssetTimetlet" & gt; & Lt; ListBoxItem Height = "70" name = "ListBoxItem" & gt; & Lt; DocPanel margin = "0,0,0,0" height = "65" & gt; & Lt; Dockpanel Dock Panel Doc = "left" name = "video dimension 2" height = "65" width = "102" & gt; & Lt; Button name = "select listboxime" click = "button-click on" tag = "{binding path = id}"> & Lt; Pathname = "test" width = "38" height = "30.0833" Canvas.Left = "19" Canvas.Top = "22.1667" Stretch = "Fill" Fill = "# FF000000" data = "F1 M 19, 34.8333 L'22.1667,34.8333L 22.1667,42.75L 19,42.75L 19,34.8333 ZM 22.9583,34.0417L 49.4791,34.0417L 49.4791,38L 50.6667,38L 57,31.6667L 57,52.25L 50.6667,45.9167L 49.4791,45.9167L 49.4791, 52.25 L 22.9583,52.25 L 22.9583,34.0417 JM 29.2 9 L7,22kl667 C 32k3522,22kl667 34k8333,24k6478 34k8333,27k7083 C 34.8333,30,7689 32.3522,33.25 29.2 917,33.25 C 26.2311,33.25 23.75,30,7689 23.75,27, 7083 C 23.75246788 26.2311,22.1667 29.2 9 17.26.1667 JM 41.9583,22.1667 C 45.0189,22.1667 47.5246478 47.527,7083 C 47.0189,33.25 41.9583,33.25 C 38.8 9 77,33.25 36.4167,30,7689 36.4167,27,7083 C 36.4167,24.6478 38.8 9 77,22.1667 41.9583,22.1667 z / "& gt; & Lt; / Button & gt; & Lt; / DockPanel & gt; & Lt; Dockpanel Doc = "Left" name = "VideoData 2" horizontal alignment = "statch" height = "65" & gt; & Lt; TextBlock DockPanel.Dock = "top" text = "{binding path = title}" FontWeight = "bold" FONTSIZE = "18" & gt; & Lt; / TextBlock & gt; & Lt; TextBlock DockPanel.Dock = "top" TextTrimming = "CharacterEllipsis" Text = "{Binding Path = Description}" TextWrapping = "nowrap" FONTSIZE = "13" Margin = "0,0,0,0" / & gt; & Lt; Stackpaneel dockpanel.doc = "top" orientation = "horizontal" & gt; & Lt; Text block text = "{binding path = video catainain}" fontisystem = "12" fontTitle = "italic" /> & Lt; Border width = "50" & gt; & Lt; / Border & gt; & Lt; Text block text = "{binding path = mediastate}" fontism = "12" /> & Lt; / StackPanel & gt; & Lt; / DockPanel & gt; & Lt; / DockPanel & gt; & Lt; / ListBoxItem & gt; & Lt; / DataTemplate & gt; & Lt; /UserControl.Resources>    

This is not the right way to themed into WPF.

But if you want a quick solution, Move InitializeComponent () statement to the bottom of its manufacturer:

  public media () { RefreshMediaList (); Darkthim = Global. Configuration. DarkModeAppleldEtheme (); InitializeComponent (); // & lt; - here}    

No comments:

Post a Comment