Problems with referencing resources.
I'm not sure if I'm just doing this wrong or there's a problem with Noesis. I defined two elements in a resource dictionary and I'm trying to reference one in the other. I shortened a lot of the actual XAML for this post.
When importing this Unity seems to go in an infinite loop. If I understand correctly you'd need a DyanmicResource for the interdependencies in the Outer resource. Why would this cause an infinite loop?
Code: Select all
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Assets/Project/Views/Resources.xaml" />
</ResourceDictionary.MergedDictionaries>
<Grid x:Key="Inner" Height="60"/>
<Grid x:Key="Outer">
<ContentControl Content="{DynamicResource Inner}" />
</Grid>
</ResourceDictionary>
</UserControl.Resources>
<ContentControl Margin="5" Content="{DynamicResource Outer}" />
</UserControl>
Re: Problems with referencing resources.
Bump? It also freezes when (I think) I use the same element twice from a resource from the same user control.
Code: Select all
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Assets/Project/Views/Resources.xaml" />
</ResourceDictionary.MergedDictionaries>
<Grid x:Key="A"/>
</ResourceDictionary>
</UserControl.Resources>
Code: Select all
<Border>
<StackPanel>
// Using it once is okay
<ContentControl Grid.Row="2" Content="{DynamicResource A}" />
// Using it twice freezes Unity.
<ContentControl Grid.Row="2" Content="{DynamicResource A}" />
</StackPanel>
</Border>
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Problems with referencing resources.
Hi and sorry for the late reply,
I was able to reproduce the freezing when using your last xaml, could you please report it in our bugtracker?
Anyway, defining UI elements as resources is not a good idea because a UI element can only have 1 single parent, so you wouldn't be able to assign it as content to different controls. What you want to do can be accomplished by using control templates:
Hope this helps.
I was able to reproduce the freezing when using your last xaml, could you please report it in our bugtracker?
Anyway, defining UI elements as resources is not a good idea because a UI element can only have 1 single parent, so you wouldn't be able to assign it as content to different controls. What you want to do can be accomplished by using control templates:
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid.Resources>
<ControlTemplate x:Key="A" TargetType="Control">
<Grid>
<!-- define here the UI you want to replicate in several controls -->
</Grid>
</ControlTemplate>
</Grid.Resources>
<Border>
<StackPanel>
<Control Grid.Row="2" Template="{StaticResource A}" />
<Control Grid.Row="2" Template="{StaticResource A}" />
</StackPanel>
</Border>
</Grid>
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: Problems with referencing resources.
Already created the report so you can track it: #1529
Who is online
Users browsing this forum: Google [Bot] and 16 guests