1

I have following hierarchy -

<TabControl x:Name="tabControl1" FontWeight="Black" BorderThickness="1" BorderBrush="Black" Background="LightBlue" >
  <local:ClosableTab Background="LightBlue" Title="New Tab" x:Name="PreviewWindow">
    <Grid>
      <Border Name="mask" Background="Black" CornerRadius="5"/>
      <Grid>
        <Grid.OpacityMask>
          <VisualBrush Visual="{Binding ElementName=mask}"/>
        </Grid.OpacityMask>
        <WebBrowser Name="webBrowser" Source="http://www.google.com" Margin="0" Navigated="webBrowser_Navigated" />
      </Grid>
    </Grid>
  </local:ClosableTab>
</TabControl>

Questions

  1. How can I bind WebBrowser with CommandParameter, by selected TabIndex of tabControl1

I am trying following code -

<Button Name="btnRefresh" Content="Refresh" Command="{Binding Path=Refresh}" CommandParameter="{Binding ElementName=tabControl1,Path=SelectedIndex}"></Button>
  1. How can I do this conditionally. e.g. If SelectedIndex>3 then Command should fire.

Update

My goal is to refresh web browser via ViewModel Command. The .xaml file has differen tabs with its own WebBrowsers, so by SelectedIndex, I can figure out that WebBrowser, which I want to pass in CommandParameter.

Marc
  • 3,905
  • 4
  • 21
  • 37
user2039445
  • 253
  • 1
  • 4
  • 17

0 Answers0