Last active
August 29, 2015 14:10
-
-
Save johannesegger/22a93f385d3bdf61942f to your computer and use it in GitHub Desktop.
MahApps sample code for issue #1690
This file contains hidden or 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
<Application x:Class="MahAppsTest.App" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
StartupUri="MainWindow.xaml"> | |
<Application.Resources> | |
<ResourceDictionary> | |
<ResourceDictionary.MergedDictionaries> | |
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> | |
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /> | |
</ResourceDictionary.MergedDictionaries> | |
</ResourceDictionary> | |
</Application.Resources> | |
</Application> |
This file contains hidden or 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
<Window x:Class="MahAppsTest.InfoWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="InfoWindow" Height="300" Width="300"> | |
<TextBox>asd</TextBox> | |
</Window> |
This file contains hidden or 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
<Window x:Class="MahAppsTest.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
mc:Ignorable="d" | |
Title="MainWindow" Height="350" Width="525"> | |
<Button Click="OpenInfoWindow_OnClick">Open window</Button> | |
</Window> |
This file contains hidden or 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
using System.Threading; | |
using System.Windows; | |
namespace MahAppsTest | |
{ | |
public partial class MainWindow | |
{ | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
} | |
private void OpenInfoWindow_OnClick(object sender, RoutedEventArgs e) | |
{ | |
var t = new Thread(() => | |
{ | |
var window = new InfoWindow(); | |
window.Show(); | |
System.Windows.Threading.Dispatcher.Run(); | |
}) { IsBackground = true }; | |
t.SetApartmentState(ApartmentState.STA); | |
t.Start(); | |
} | |
} | |
} |
Thanks, I tried that, but still, using MahApps.Metro's ResourceDictionary
s it fails. Anyway, I will update the gist.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I guess your thread should look like this:
See Running WPF Application with Multiple UI Threads