Xaml文件看不到命名空间中的类

时间:2019-05-26 12:48:42

标签: c# xaml namespaces

为什么static final int GOOGLE_SIGN_IN = 123; FirebaseAuth mAuth; Button btn_login, btn_logout; TextView text; ImageView image; ProgressBar progressBar; GoogleSignInClient mGoogleSignInClient; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); btn_login = findViewById(R.id.login); btn_logout = findViewById(R.id.logout); text = findViewById(R.id.text); image = findViewById(R.id.image); progressBar = findViewById(R.id.progress_circular); mAuth = FirebaseAuth.getInstance(); GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build(); mGoogleSignInClient = GoogleSignIn.getClient(this, gso); btn_login.setOnClickListener(v -> SignInGoogle()); btn_logout.setOnClickListener(v -> Logout()); if (mAuth.getCurrentUser() != null) { FirebaseUser user = mAuth.getCurrentUser(); updateUI(user); } } public void SignInGoogle() { progressBar.setVisibility(View.VISIBLE); Intent signInIntent = mGoogleSignInClient.getSignInIntent(); startActivityForResult(signInIntent, GOOGLE_SIGN_IN); } private void firebaseAuthWithGoogle(GoogleSignInAccount acct) { Log.d("TAG", "firebaseAuthWithGoogle:" + acct.getId()); AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null); mAuth.signInWithCredential(credential) .addOnCompleteListener(this, task -> { if (task.isSuccessful()) { progressBar.setVisibility(View.INVISIBLE); Log.d("TAG", "signInWithCredential:success"); FirebaseUser user = mAuth.getCurrentUser(); updateUI(user); } else { progressBar.setVisibility(View.INVISIBLE); Log.w("TAG", "signInWithCredential:failure", task.getException()); Toast.makeText(LoginActivity.this, "Authentication failed.", Toast.LENGTH_SHORT).show(); updateUI(null); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == GOOGLE_SIGN_IN) { Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data); try { GoogleSignInAccount account = task.getResult(ApiException.class); if (account != null) firebaseAuthWithGoogle(account); } catch (ApiException e) { Log.w("TAG", "Google sign in failed", e); } } } private void updateUI(FirebaseUser user) { if (user != null) { String name = user.getDisplayName(); String email = user.getEmail(); String photo = String.valueOf(user.getPhotoUrl()); for (UserInfo userInfo : user.getProviderData()) if (name == null && userInfo.getDisplayName() != null) name = userInfo.getDisplayName(); text.append("Info : \n"); text.append(name + "\n"); text.append(email); Picasso.get().load(photo).into(image); btn_logout.setVisibility(View.VISIBLE); btn_login.setVisibility(View.INVISIBLE); } else { text.setText("Distress Alert\n"); btn_logout.setVisibility(View.INVISIBLE); btn_login.setVisibility(View.VISIBLE); Picasso.get().load(R.drawable.ic_firebase_logo).into(image); } } private void Logout() { FirebaseAuth.getInstance().signOut(); mGoogleSignInClient.signOut().addOnCompleteListener(this, task -> updateUI(null)); } App.xml文件中找不到类CaptionButtonRectToMarginConverter

Shell \ CaptionButtonRectToMarginConverter.cs

App.xml

Error XDG0008 File App.xml Line 13

The name "CaptionButtonRectToMarginConverter" does not exist in the namespace
"clr-namespace:ErdBuilder.Shell".

Shell \ CaptionButtonRectToMarginConverter.cs

<nRoute:Application x:Class="ErdBuilder.App"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:nRoute="http://nRoute/schemas/2010/xaml"
                    xmlns:chronos="http://chronos/schemas/2010/xaml"
                    xmlns:shell="clr-namespace:ErdBuilder.Shell"
                    StartupUri="Shell\Shell.xaml"
                    ShutdownMode="OnMainWindowClose">

    <nRoute:Application.Resources>
        <ResourceDictionary>

            <shell:CaptionButtonRectToMarginConverter x:Key="CaptionButtonMarginConverter" />

0 个答案:

没有答案