Reputation: 177
I have a setup working where i can bind my grid.row properties of a rectangle to an integer in a class in the source behind, but I would really like to be able to use array's of integers instead of integers. The code I had worked when gridColumn was a simple integer but not when it is put into an array like so:
C# code:
namespace WPFTestingApplication
{
public static class GridProperties
{
public static int[] gridColumn = { 1, 0 };
}
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
XAML:
<Window x:Class="WPFTestingApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFTestingApplication"
Title="MainWindow" Height="200" Width="400">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle Name="Rect" Grid.Column="{Binding Source={x:Static
local:GridProperties.gridColumn[0]}}" Fill="DarkGray" Margin="5" />
</Grid>
</Window>
Upvotes: 4
Views: 1782
Reputation: 12295
Grid.Column="{Binding [0], Source={x:Static Member=local:GridProperties.gridColumn}}"
I hope this will help.
Upvotes: 2