2012-07-31 57 views
0

我試圖編輯在C#源代碼 形式與WPF寫,並在他們不直接宣佈 性能但參考下面 使用我把一些線路從WPF形式。編輯WPF代碼,是指資源

<Grid> 
    <StackPanel> 
     <Label> 
      <LocText ResourceIdentifierKey="CustomerName" Suffix=":"/> 
     </Label> 
     <TextBox HorizontalAlignment="Left" MinWidth="200" Text="{Binding Name}" /> 
     <Label> 
      <LocText ResourceIdentifierKey="GroupCode" Suffix=":"/> 
     </Label> 
     <ComboBox HorizontalAlignment="Left" MinWidth="150" Text="{Binding  GroupCode,Mode=TwoWay}" 
        ItemsSource="{Binding GroupCodes}" IsEditable="True"/> 
     <Label> 
      <LocText ResourceIdentifierKey="PhoneNumber" Suffix=":"/> 
     </Label> 
     <Common:MaskedTextBox HorizontalAlignment="Left" MinWidth="100" InputMask="{Binding PhoneNumberInputMask}" 
      PromptChar=" " UnmaskedText="{Binding PhoneNumber, Mode=TwoWay, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" /> 
     <Label> 
      <LocText ResourceIdentifierKey="Address" Suffix=":"/> 
     </Label> 
     <TextBox HorizontalAlignment="Left" MinWidth="200" MinHeight="55" Text="{Binding Address}" 
      AcceptsReturn="True" /> 
     <Label> 
      <LocText ResourceIdentifierKey="Note" Suffix=":"/> 
     </Label> 
     <TextBox HorizontalAlignment="Left" MinWidth="200" MinHeight="55" Text="{Binding Note}" 
      AcceptsReturn="True" /> 
     <CheckBox Margin="0,5,0,0" IsChecked="{Binding InternalAccount}"> 
      <LocText ResourceIdentifierKey="InternalAccount"/> 
     </CheckBox> 
     <Button HorizontalAlignment="Left" Margin="0,10" MinWidth="70" Content="{Binding SaveCommand.Caption}" 
      Command="{Binding SaveCommand}" /> 
     <Label Content="{Binding Error}" Foreground="Red" /> 
    </StackPanel> 
</Grid> 

如何編輯屬性?

例如,我想更改標籤的內容。

+0

問題是什麼?如何編輯源代碼?與鍵盤:)或如何讓用戶編輯一些文字,而不是隻顯示它?還是別的? – dvvrd 2012-08-02 10:48:04

回答

0

很難知道你在問什麼 - 如果你想編輯源代碼,只需在Visual Studio中加載文件並輸入即可。

如果要在運行時更改標籤的內容,有兩種方法。

一種是使用綁定將標籤掛鉤到與您的form/usercontrol關聯的DataContext對象上的屬性。

其他將是給標籤的實際名稱:

<Label x:Name="showAccountError Foreground="Red"/> 

,然後你可以在代碼中設置內容:

showAccountError.Content = "Sample error";