콤보 상자에 기본값으로 'select'를 추가해야합니다.이 값을 데이터베이스에 추가 할 수 없습니다.이 위치 값은 동적입니다.이 값은 userrole에 따라 달라집니다. 나는 다른 방법으로 아무 것도 노력하지 못했습니다. 제발 도와주세요. wpf 콤보 상자의 기본값을 textBlock
<ComboBox Width="140" ItemsSource="{Binding SecurityContexts, Mode=OneWay}"
SelectedItem="{Binding ActiveSecurityContext, Mode=TwoWay}"
ToolTip="Working Location">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Location}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
코드 뒤에 SecurityContexts = ObservableCollection에 새로운 (_currentUser.ApplicationSecurityContexts)이고;
public interface IApplicationSecurityContext
{
IRole Role { get; }
string Location { get; }
IEnumerable<string> Budgets { get; }
}
public IApplicationSecurityContext ActiveSecurityContext
{
get { return this._currentUser.ActiveSecurityContext; }
set
{
if (this._currentUser.ActiveSecurityContext != value)
{
this._currentUser.ChangeActiveSecurityContext(value);
RaisePropertyChanged("CurrentUser");
LoadData();
}
}
}
것은 당신이 실제로가는 당신이 사용자 정의 개체를 정의 된 경로는 다음과 같습니다 당신은 당신의 항목이 C C에 그
참고 표시되는 방법을 정의 할 수도 자원의 컬렉션에 대한 귀하의 DataTemplate을 정의해야 : 콤보 상자 항목으로 표시되어야하는 "위치"속성을 노출하는 SecurityContexts 클래스 모음이 있습니다. 하나의 요소를 올바르게 추가하기 만하면됩니까? –
오타와 죄송합니다. 그것은 나의 이전 코멘트에서 "가는"대신에 "하고있다". 그러나 당신이 우리에게 몇 가지 설명을하지 않으면 당신에게 대답을하기가 어려울 것입니다. 아마도 xaml뿐 아니라 특히 "SecurityContexts"가 무엇인지, 무엇이 만들어 졌는지 코드를 게시 할 수 있습니다. –
추가 된 코드를 확인해 주셔서 감사합니다. 콤보 박스는 사용자의 역할에 따라 location1, location5 등을 표시합니다 ... 나는 단지 콤보 상자에 기본값 'select'를 추가해야합니다. – newbee