-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support color coded names in party view (#135)
* Simplify colored text binding using extension Support color coded names in party view * Remove commented out code
- Loading branch information
1 parent
fe65296
commit 38c2666
Showing
5 changed files
with
68 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Documents; | ||
|
||
using H2MLauncher.UI.Converters; | ||
|
||
namespace H2MLauncher.UI | ||
{ | ||
public static class TextBlockExtensions | ||
{ | ||
public static IEnumerable<Inline> GetBindableInlines(DependencyObject obj) | ||
{ | ||
return (IEnumerable<Inline>)obj.GetValue(BindableInlinesProperty); | ||
} | ||
|
||
public static void SetBindableInlines(DependencyObject obj, IEnumerable<Inline> value) | ||
{ | ||
obj.SetValue(BindableInlinesProperty, value); | ||
} | ||
|
||
public static readonly DependencyProperty BindableInlinesProperty = | ||
DependencyProperty.RegisterAttached("BindableInlines", typeof(IEnumerable<Inline>), typeof(TextBlockExtensions), new PropertyMetadata(null, OnBindableInlinesChanged)); | ||
|
||
private static void OnBindableInlinesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) | ||
{ | ||
if (d is not TextBlock target) | ||
{ | ||
return; | ||
} | ||
|
||
if (target != null) | ||
{ | ||
target.Inlines.Clear(); | ||
target.Inlines.AddRange(((System.Collections.IEnumerable)e.NewValue)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters