I’ve inherited a UserControl to add some functionality, and it works great. MyUserControl is in a different project, and I simply use it in main project, the problem is that anytime I open the xaml it will not render until I make a change and build. After that the layout refreshes all the time, but if I close the user control and reopen it does not display anything unless I build. Here is the xaml
<cc:FormUserControl x:Class="Module.Options.Views.Accounting.Views.JournalFormView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="clr-namespace:Module.Common.Controls;assembly=Module.Common">
<TextBox Grid.Row="1" Text=”Some Text” />
</cc:FormUserControl>
Here is the c#
public class FormUserControl : UserControl, IView
{
public FormUserControl()
{
SetValue(ViewModelLocator.AutoWireViewModelProperty, true);
}
public override void EndInit()
{
if (CanRefresh)
{
Resources.MergedDictionaries.Add(
new ResourceDictionary().AddResource("/Resource.Dictionaries;component/Styles/MyControlStyle.xaml"));
Style = FindResource("MyserControlStyle") as Style;
}
base.EndInit();
}
public bool CanRefresh
{
get { return (bool)GetValue(CanRefreshProperty); }
set { SetValue(CanRefreshProperty, value); }
}
public static readonly DependencyProperty CanRefreshProperty =
DependencyProperty.Register("CanRefresh", typeof(bool), typeof(FormUserControl), new PropertyMetadata(false));
}
There is nothing special about this code and I don’t know why it does not refresh until I buid. These two files are in different projects, and the xaml will work as soon as I do anychange like add space and build. Any ideas?
Kind Regards