Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to bind the width of a Grid column to a property

$
0
0

I am trying to figure out how to have dynamic column widths in a grid that is inside a ListView. I have successfully got the row height of the ListView bound but (<ColumnDefinition Width="{Binding PictureWidth}" />) seems to have no affect. If i set it to a hard number (<ColumnDefinition Width="60" />) it works fine...?

<ListView   x:Name="listView" ItemsSource="{Binding ParentPage.Patients.Patients}" RowHeight="{Binding RowHeight}"  >
      <ListView.ItemTemplate>
        <DataTemplate>
          <ViewCell>
            <Grid HorizontalOptions="FillAndExpand">
              <Grid.RowDefinitions>
                <RowDefinition Height="*" />
              </Grid.RowDefinitions>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="{Binding PictureWidth}" />
                <ColumnDefinition Width="*" />
              </Grid.ColumnDefinitions>
              <Image  Grid.Row="0" Grid.Column="0"
                 Source="{Binding Picture}"
                  />

              <Label BindingContext="{x:Reference PictureWidthSlider}" TextColor="Green" Text="{Binding Value}"
           HorizontalOptions="Center" />
              <Label BindingContext="{x:Reference RowHeightSlider}" TextColor="Red" Text="{Binding Value}"
           HorizontalOptions="Center" />

              <Label  Grid.Row="0" Grid.Column="1"
                      Text="{Binding FullName}"  />             
            </Grid>     
          </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>