Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How can I add a style trigger to a RowDefiniton in xaml?

I have been trying to make my value of my row height update depending on if the device is portrait mode or not (set in the view model). I can't seem to find a way to add a trigger to a row definition to do this. Is there a way?


  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    Would be a trigger? Wouldn't it just bind to a customRowHeight property on the ViewModel (not the model in the collection)?

    Maybe the problem is that its looking for the value on the model in the collection and not higher up on the ViewModel. That's a common mistake. Are you specifically setting the source as the VM?

    It would help if we saw your XAML. (please use markdown so the site parser doesn't eat it)

  • PenutButterJellyHeadPenutButterJellyHead USMember ✭✭✭
    edited March 2018

    this is my image

  • PenutButterJellyHeadPenutButterJellyHead USMember ✭✭✭
    edited March 2018

    <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> <RowDefinition> <RowDefinition.Style> <Style> <Setter Property="RowDefinition.Height" Value="0"/> <Style.Triggers> <DataTrigger Binding="{Binding IsPortraitMode}" Value="True"> <Setter Property="RowDefinition.Height" Value="*"/> </DataTrigger> </Style.Triggers> </Style> </RowDefinition.Style> </RowDefinition> </Grid.RowDefinitions>

  • PenutButterJellyHeadPenutButterJellyHead USMember ✭✭✭

    Im trying to not set my actual values in my view model, but update the RowDefinition in my xaml based on a boolean coming from my view model. Is there a way to use a trigger with RowDefinition?

Sign In or Register to comment.