Changing Grid.GetRowDefinitions Grid.GetColumnDefinitions via attached property not working
Posted: 04 Nov 2019, 21:58
Hi There
I am trying to implement an example Inventory Screen in Unreal Engine 4.22.2 with Noesis. A part of this inventory screen consists of a Grid which shows the content of a backpack or vest or the like. The grid needs to be setup dynamically (Number of columns/rows) depending on the size of backpack/vest but the grid itself will be evenly distributed.
By the way: We don't use your "unreal to noesis" type wrappers since our view models are pure C++ with Noesis, without any UE code or uproperties/ufunctions, however we use the Noesis UEPlugin of course.
The xaml around the grid looks like:
So I am using the attached properties WpfGridExtensions.ColumnCount and WpfGridExtensions.RowCount which in turn use their ProperyChanged callback to setup the Grid's Column/Row Definitions:
The RowCountPropertyChangedCallback does the same with rowDefinitions. What I expect is that the grid would be setup similar to the following XAML:
The attached properties are working, the C++ PropertyChanged callbacks are called and seem to execute correctly, so the XXXDefinintions->Add(...) return values >= 0, but there is no visible effect, the Grid stays in a "collapsed" state in C++/UE4, while it is perfectly working in C#/WPF with the "corresponding C# code" and inside the visual studio designer with a designtime viewmodel.
There are no errors Reported in the UE Noesis Logoutput when I open the view, the LogLevel is set to "Bindings".
Am I missing something?
I am trying to implement an example Inventory Screen in Unreal Engine 4.22.2 with Noesis. A part of this inventory screen consists of a Grid which shows the content of a backpack or vest or the like. The grid needs to be setup dynamically (Number of columns/rows) depending on the size of backpack/vest but the grid itself will be evenly distributed.
By the way: We don't use your "unreal to noesis" type wrappers since our view models are pure C++ with Noesis, without any UE code or uproperties/ufunctions, however we use the Noesis UEPlugin of course.
The xaml around the grid looks like:
Code: Select all
...
<ItemsControl Grid.Row="2" ItemsSource="{Binding SubObjectSockets}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Grid doiUi:WpfGridExtensions.ColumnCount="5" doiUi:WpfGridExtensions.RowCount="2" />
<!-- <Grid doiUi:WpfGridExtensions.ColumnCount="{Binding XSize}" doiUi:WpfGridExtensions.RowCount="{Binding YSize}" /> -->
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Grid.Row" Value="{Binding YPos}" />
<Setter Property="Grid.Column" Value="{Binding XPos}" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Canvas Height="50" Width="50"></Canvas>
<Image Margin="3,3,3,3" Source="{Binding ObjectImage}" Stretch="Uniform" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
...
Code: Select all
...
static void ColumnCountPropertyChangedCallback(Noesis::DependencyObject* obj, const Noesis::DependencyPropertyChangedEventArgs& args)
{
Noesis::Grid* grid = Noesis::DynamicCast<Noesis::Grid*>(obj);
if(!grid) return;
int columnCount = *static_cast<const int*>(args.newValue);
if(columnCount < 0) return;
Noesis::ColumnDefinitionCollection* columnDefinitions = grid->GetColumnDefinitions();
columnDefinitions->Clear();
for(int i = 0; i < columnCount; ++i) {
auto columnDefinition = new Noesis::ColumnDefinition();
columnDefinition->SetWidth(Noesis::GridLength(1.0f, Noesis::GridUnitType_Star));
columnDefinitions->Add(columnDefinition);
}
}
...
Code: Select all
...
<ItemsPanelTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<!-- a dynamic number of such ColumnDefinitions... -->
<Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<!-- a dynamic number of such RowDefinitions... -->
</Grid.RowDefinitions>
</Grid>
</ItemsPanelTemplate>
...
There are no errors Reported in the UE Noesis Logoutput when I open the view, the LogLevel is set to "Bindings".
Am I missing something?