I'm using Modern UI for my WPF project.
I have 2 questions:
I have
mui:ModernTab Layout="List"
which means aListCollection
, and i want to bind a click on one of theLinks
(I guess to bindmouseleftbuttonup
), is it possible? (I need it because i have the sameSource
xaml for all of the links).And if i can do this, is there anyway to detect what is the
DisplayName
of the clickedLink
?
Code:
<UserControl x:Class="MyApp.Pages.Results.SecondPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mui="http://firstfloorsoftware.com/ModernUI"
xmlns:local="clr-namespace:MyApp.Pages.Results"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<mui:ModernTab Layout="List" Links="{Binding Path=SomeLinks}">
</mui:ModernTab>
</Grid>
</UserControl>
The View Model:
class ViewModel : NotifyPropertyChanged
{
private Uri My_URI = new Uri("/Pages/Results/MyList.xaml", UriKind.Relative);
private LinkCollection someLinks;
private string path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
public ResultsViewModel()
{
someLinks= new LinkCollection();
add_to_list(someLinks);
}
public void add_to_list(LinkCollection someLinks)
{
XDocument xdoc = XDocument.Load(path + @"\Pages\Results\Target_XML.xml");
List<string> names= xdoc.Elements().Elements().Elements().Select(x => x.Name.LocalName).ToList();
foreach (string ing_name in names)
someLinks.Add(new Link() { DisplayName = ing_name, Source = My_URI});
}
public LinkCollection SomeLinks
{
get { return this.someLinks; }
}