Getting the ComboBox disabled took me a while and with a few searches, nothing came up.
My first attempt at getting this to work.
<ComboBox
x:Name="buildingCmb"
Grid.Row="2" Grid.Column="2"
ItemsSource="{Binding Path=Buildings, Mode=OneWay}"
DisplayMemberPath="Name"
SelectedValuePath="Id"
SelectedValue="{Binding Path=BuildingId}"
Validation.ErrorTemplate="{x:Null}"
HorizontalAlignment="Left"
Width="250"
IsEnabled="{Binding Path=IsReadOnly}">
</ComboBox>
After another search, I found this article, where the answer explained that to disable a combobox control you need to set the IsHitVisible, Focusable and IsEditable properties.
Then came my next attempt, just adding the new properties to the combobox.
<ComboBox
x:Name="buildingCmb"
Grid.Row="2" Grid.Column="2"
ItemsSource="{Binding Path=Buildings, Mode=OneWay}"
DisplayMemberPath="Name"
SelectedValuePath="Id"
SelectedValue="{Binding Path=BuildingId}"
Validation.ErrorTemplate="{x:Null}"
HorizontalAlignment="Left"
Width="250"
IsEnabled="{Binding Path=IsReadOnly}">
Focusable="{Binding Path=IsReadOnly}"
IsHitTestVisible="{Binding Path=IsReadOnly}"
</ComboBox>
That did not work either, then I came across another article, showing the use of DataTriggers with a combobox. What I came up with is the following, which works.
<ComboBox
x:Name="buildingCmb"
Grid.Row="2" Grid.Column="2"
ItemsSource="{Binding Path=Buildings, Mode=OneWay}"
DisplayMemberPath="Name"
SelectedValuePath="Id"
SelectedValue="{Binding Path=BuildingId}"
Validation.ErrorTemplate="{x:Null}"
HorizontalAlignment="Left"
Width="250">
<ComboBox.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsReadOnly}" Value="False">
<Setter Property="ComboBox.Focusable" Value="False"/>
<Setter Property="ComboBox.IsEnabled" Value="False"/>
<Setter Property="ComboBox.IsHitTestVisible" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ComboBox.Style>
</ComboBox>
The DataTrigger is explained by it's own attributes.
<DataTrigger Binding="{Binding Path=IsReadOnly}" Value="False">
How it works is, it binds to the property IsReadOnly and if it is the same as the Value attribute's value, it will set the rest of the properties for the ComboBox.
I also changed the IsEnabled property to IsEditable as it then does not show the ComboBox as disabled.