2015-10-05 53 views
0

我面临着一些问题,试图实现从这里装载微调:https://github.com/blackspikeltd/Xaml-Spinners-WPFMVVM WPF空的用户控制

我的主窗口仅仅是我在那里装载由一个按钮控制不同的用户控件的包装:

<Window x:Class="Project.Desktop.Views.MainWindow" 
    xmlns:animations="clr-namespace:Project.Desktop.Helpers.Animations" 
    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" 
    xmlns:views="clr-namespace:Project.Desktop.Views" 
    xmlns:viewModels="clr-namespace:Project.Desktop.ViewModels" 
    Title="Project" Height="580" Width="1024" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" MouseLeftButtonDown="OnMouseLeftButtonDownMove"> 

    <Window.Resources> 
     <DataTemplate DataType="{x:Type viewModels:WelcomeVM}"> 
      <views:Welcome /> 
     </DataTemplate> 
     <DataTemplate DataType="{x:Type viewModels:GameSelectVM}"> 
      <views:GameSelect /> 
     </DataTemplate> 
    </Window.Resources> 


    <Grid> 
     <ContentControl Content="{Binding CurrentPageViewModel}" /> 
    </Grid> 
</Window> 

我复制了XML到我在我的项目创建这样的引用的用户控制视图:

xmlns:animations="clr-namespace:Project.Desktop.Helpers.Animations" 

,然后我试图访问用户控件与

<animations:LoadingAnimation HorizontalAlignment="Center" VerticalAlignment="Center" /> 

的问题是,我不能看到正在加载的旋转,就好像不存在,我相信还有其他的用户控制之间的冲突,但我不能够解决这个问题,主要是因为我新的wpf和xml。

谢谢。

回答

0

我相信我发现了一个解决方案,我需要定义一个DataContext为自己的用户控件:

<animations:LoadingAnimation DataContext="{Binding RelativeSource={RelativeSource Self}}" HorizontalAlignment="Center" VerticalAlignment="Center" />