Re: A few questions about some features
And I imagine it works fine in the XamlPlayer right?
Ok, I will try to do the same, using the UserControl tutorial code in the Integration Sample.
Ok, I will try to do the same, using the UserControl tutorial code in the Integration Sample.
Re: A few questions about some features
Yes it does work in the XamlPlayer.
Thank you for your help
Thank you for your help

Re: A few questions about some features
I have found a very strange bug that I think is the problem you are observing. Unfortunately, a new version is required to solve it. Could you please file a bug? I will provide you a hotfix for evaluation.
Thanks!
Thanks!
-
-
sfernandez
Site Admin
- Posts: 3222
- Joined:
Re: A few questions about some features
I've been looking at this code and I think there is something wrong with the design.My second problem is a bit more mysterious. As I said, I'm trying to spawn controls from my application code. One of my goals is to fill a StackPanel with a custom control containing a custom drop down menu. But as soon as I try to add one in the Panel (using UIElementCollection::Add), the application crashes. Here are some code snippets:
test.xaml, loaded by the application:filterBar.xamlCode: Select all<Border xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="PART_BorderTest" UseLayoutRounding="True"> <FilterBar x:Name="PART_FilterBar" /> </Border>
filterCategory.xamlCode: Select all<FilterBar xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="FilterBar" x:Name="FilterBar" UseLayoutRounding="True"> <StackPanel x:Name="PART_CategoryPanel" Orientation="Horizontal" /> </FilterBar>
Note that I've encountered both problems using that ControlTemplate for MenuAnchor (the custom drop down menu) shown in filterCategory.xaml.Code: Select all<FilterCategory xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="FilterCategory" x:Name="FilterCategory" UseLayoutRounding="True"> <FilterCategory.Resources> <ControlTemplate x:Key="MenuAnchorTemplate" TargetType="{x:Type MenuAnchor}"> <StackPanel Orientation="Vertical"> <StackPanel Orientation="Horizontal"> <ContentPresenter x:Name="PART_HeaderContent" Content="{Binding HeaderContent, RelativeSource={RelativeSource TemplatedParent}}"/> <ToggleButton IsChecked="{Binding IsMenuOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/> </StackPanel> <Popup x:Name="PART_Popup" IsOpen="{Binding IsMenuOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Focusable="False" PlacementTarget="{Binding ElementName=PART_HeaderContent}" Placement="Bottom" PopupAnimation="Slide" VerticalOffset="1" AllowsTransparency="True" StaysOpen="True"> <ContentPresenter/> </Popup> </StackPanel> </ControlTemplate> <Style TargetType="{x:Type MenuAnchor}"> <Setter Property="Template" Value="{StaticResource MenuAnchorTemplate}"/> </Style> </FilterCategory.Resources> <MenuAnchor> <MenuAnchor.HeaderContent> <StackPanel Orientation="Horizontal"> <CheckBox/> <TextBlock Text="{Binding CategoryID, Mode=TwoWay, StringFormat=F2}" /> </StackPanel> </MenuAnchor.HeaderContent> <StackPanel x:Name="PART_FilterPanel" Orientation="Vertical"/> </MenuAnchor> </FilterCategory>
Add functionCode: Select allNoesis::Gui::UIElementCollection* pCol = _filtersCategoriesPanel->GetChildren(); if (pCol != nullptr) { pCol->Add(pNewCategory); }
Custom Controls don't have a xaml associated with the class, so when you reference a custom control from another xaml like in test.xaml, you cannot expect that FilterBar instance will contain a StackPanel named "PART_CategoryPanel" set as content. PART_ elements must be defined in the control template in the same way you did with the MenuAnchorTemplate.
If you need to associate a xaml with a control, then you need to create a UserControl, and override the UserControl.Source property to specify which xaml file must be loaded when your user control gets created.
I tried to add some custom controls to a panel without problem so my guess is that the crash you were getting was because the _filtersCategoriesPanel was null (maybe you were assuming that filterCategory.xaml would be loaded and PART_FilterPanel element could be found). Could that be possible?
Re: A few questions about some features
Hi,
I've let that part in stand-by for a quite a while now, I'll have another look at it and let you know if I encounter problems. I've learned quite a lot about the framework since then.
Thank you!
I've let that part in stand-by for a quite a while now, I'll have another look at it and let you know if I encounter problems. I've learned quite a lot about the framework since then.
Thank you!
-
-
sfernandez
Site Admin
- Posts: 3222
- Joined:
Re: A few questions about some features
Coming back to this issue I guess this problem was related with the serialization bug we solved in 1.2.2.It's working great, thank you so much!
Actually, it works in the XamlPlayer, but as soon as I try to integrate it in my application, bad things happens.As soon as I uncomment the Border resources, I get that error:Code: Select all<Border xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="Root" BorderBrush="White" BorderThickness="1" HorizontalAlignment="Center" VerticalAlignment="Center"> <!--<Border.Resources> <ResourceDictionary> <InventoryTileModel x:Key="model" ItemID="0" Quantity="10" /> </ResourceDictionary> </Border.Resources>--> <Image Source="./assets/woodicon.png" Height="60" Width="60" /> </Border>
The weird thing is that everything is working in the XamlPlayer. Do you have a lead on what might be wrong with that? Thank you.Code: Select allFile Core\Kernel\Src\Memory.cpp (l. 130): Not enough memory! (malloc(15627680408))
Could you also check that setting back the view model in the xaml is working as expected?
Thanks for your collaboration.
Who is online
Users browsing this forum: Google [Bot] and 3 guests