Suppose I have a block, in which all banding is tied to the parameters of a single object. Does it make sense (in terms of performance) to bring it to the top level in the DataContext or is there no significant difference?
For example, with DataContext :
<StackPanel mui:Switch.When="{x:Static t:ServerStatus.Error}" DataContext="{Binding Entry}"> <!-- server's name --> <TextBlock Text="{Binding DisplayName}" /> <!-- ip, ping --> <TextBox> <TextBox.Text> <MultiBinding StringFormat="{}{0}:{1}"> <Binding Path="Ip" Mode="OneWay" /> <Binding Path="PortHttp" Mode="OneWay" /> </MultiBinding> </TextBox.Text> </TextBox> <mui:BbCodeBlock BbCode="{Binding ErrorsString}" /> <Button Command="{Binding RefreshCommand}" Content="{x:Static c:ControlsStrings.Common_TryAgain}" /> </StackPanel> And without:
<StackPanel mui:Switch.When="{x:Static t:ServerStatus.Error}"> <!-- server's name --> <TextBlock Text="{Binding Entry.DisplayName}" /> <!-- ip, ping --> <TextBox> <TextBox.Text> <MultiBinding StringFormat="{}{0}:{1}"> <Binding Path="Entry.Ip" Mode="OneWay" /> <Binding Path="Entry.PortHttp" Mode="OneWay" /> </MultiBinding> </TextBox.Text> </TextBox> <mui:BbCodeBlock BbCode="{Binding Entry.ErrorsString}" /> <Button Command="{Binding Entry.RefreshCommand}" Content="{x:Static c:ControlsStrings.Common_TryAgain}" /> </StackPanel> And then I have some miracles here because of AddLogicalChild along with this very DataContext , I can’t even imagine where to dig.
AddLogicalChild? o_O - VladDAddLogicalChilduse in my panel (here you can see one of its properties,mui:Switch.When) to switch between controls by condition. So at least in XAML-code looks more elegant than all theseVisibility={Binding …, Converter=…, ConverterParameter=…}. Well, I want to believe that it works faster. - Surfin Bird