2014-09-29 2 views
1

실버 라이트 응용 프로그램에 콤보 상자가 있고 그 안에 확인란과 텍스트 상자가 있는데 ComboBox의 선택된 값을 설정해야하지만 선택되지는 않습니다 나는 this 링크를 따르고 있습니다. 그것 작동하지 않음이이 실버 라이트 콤보 상자 선택 값

private string _selectdType = ""; 
public string SelectedType 
{ 
    get { return _selectdType; } 
    set 
    { 
     _selectdType = value; 
     MessageBox.Show(_selectdType); 
     NotifyOfPropertyChange("SelectedType"); 
    } 
} 

내 뷰 모델 생성자 내 SelectedProperty

내 콤보

<ComboBox x:Name="Types" SelectedValue="{Binding SelectedType, Mode=TwoWay}" VerticalAlignment="Top" Margin="2,8,-2,0" Grid.ColumnSpan="3" Height="28" Padding="3">       
    <ComboBoxItem Tag="All"> 
     <Grid HorizontalAlignment="Stretch"> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="20"/> 
       <ColumnDefinition Width="*" MinWidth="105" /> 
       <ColumnDefinition Width="60" /> 
      </Grid.ColumnDefinitions> 
      <CheckBox Name="all" VerticalAlignment="Center" Grid.Column="0"/> 
      <TextBlock Text="All" VerticalAlignment="Center" Grid.Column="1" Style="{x:Null}" FontSize="11"/>        
     </Grid> 
    </ComboBoxItem> 
    <ComboBoxItem Tag="General"> 
     <Grid HorizontalAlignment="Stretch"> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="20"/> 
       <ColumnDefinition Width="*" MinWidth="105" /> 
       <ColumnDefinition Width="60" /> 
      </Grid.ColumnDefinitions> 
      <CheckBox Name="General" VerticalAlignment="Center" Grid.Column="0" /> 
      <TextBlock Text="General" VerticalAlignment="Center" Grid.Column="1" Style="{x:Null}" FontSize="11"/> 
      <TextBox Text="180" VerticalAlignment="Center" Grid.Column="2" FontSize="11" Padding="2" HorizontalContentAlignment="Right"/> 
     </Grid> 
    </ComboBoxItem> 
</ComboBox> 

, 나는이

,691,363처럼 설정하고210
public MyViewModel() 
{ 
    SelectedType="All"; 
} 

그러나 ComboBox는 선택된 값없이 표시됩니다 (예 : 공백). 나는 또한 이름 속성 대신에 태그 만 제대로 작동 할 수 있도록

+0

당신이 변환기와 바인딩을 디버깅하는 것을 시도했다 .. ? – Sankarann

+0

아니요, 저는 실버 라이트가 새롭습니다. 어떻게 할 수 있습니까? –

답변

1

당신은 SelectedValue에 대한 SelectedValuePath 속성을 설정해야합니다 행운과 노력 :

<ComboBox x:Name="Types" 
      SelectedValuePath="Tag" 
      ...... 
      > 
    ...... 
</ComboBox> 
+0

감사합니다. –