-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Error-Highlighting by hover above
- Loading branch information
Showing
7 changed files
with
192 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace Arma.Studio.Data.UI | ||
{ | ||
public class RelayDataTemplateSelector : DataTemplateSelector | ||
{ | ||
private readonly Control RelayTo; | ||
public RelayDataTemplateSelector(Control control) | ||
{ | ||
this.RelayTo = control; | ||
} | ||
|
||
public override DataTemplate SelectTemplate(object item, DependencyObject container) | ||
{ | ||
var baseResult = base.SelectTemplate(item, container); | ||
if (baseResult != null || item is null) | ||
{ | ||
return baseResult; | ||
} | ||
var objType = item.GetType(); | ||
var matches = this.RelayTo.Resources | ||
.Cast<DictionaryEntry>() | ||
.Select((it) => it.Value) | ||
.Where((it) => it is DataTemplate) | ||
.Cast<DataTemplate>() | ||
.Where((it) => it.DataType is Type t && t.IsAssignableFrom(objType)).ToArray(); | ||
if (!matches.Any()) | ||
{ | ||
return null; | ||
} | ||
// ToDo: Find the best match | ||
var template = matches.First(); | ||
return (DataTemplate)template; | ||
} | ||
} | ||
} |
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
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