Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransitioningContentControl Help! #754

Closed
cod3n00b opened this issue Oct 30, 2013 · 14 comments
Closed

TransitioningContentControl Help! #754

cod3n00b opened this issue Oct 30, 2013 · 14 comments

Comments

@cod3n00b
Copy link

I need help on using this control. I have 2 Grid control with children controls that are being created dynamically. Now, when I changed the content property of the TransitioningContentControl to one of the grids. It works pretty fine. But when changing it again to another Grid Control. It works fine but with annoying errors that pops in my Immediate window.

System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TransparentWhiteBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='VerticalScrollBar'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='VerticalScrollBar'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TransparentWhiteBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TransparentWhiteBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='VerticalScrollBar'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='VerticalScrollBar'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TransparentWhiteBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TransparentWhiteBrush'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='VerticalScrollBar'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='VerticalScrollBar'
System.Windows.ResourceDictionary Warning: 9 : Resource not found; ResourceKey='TransparentWhiteBrush'

I hope someone could help me here. Thanks in advance.

@punker76
Copy link
Member

@cod3n00b which version? and show us a little code. thx

@punker76
Copy link
Member

@cod3n00b
Copy link
Author

Oh Sorry about that! I thought my problem could be visualized by just telling it.

Here is my xaml code using the TransitioningContentControl
transitioningcontentcontrol

Here is my code in VB.NET that is a click event of a button.
transitioningcontentcontrol2

The TransitionContentControl's Content Property doesn't have any value when the form is loaded. When I clicked the Next button at the first time. It will show the first dynamically grid with children controls (textboxes, combo boxes, etc.) on it without any problems. But the second time you clicked. It will show the second grid that I've created dynamically that also have children controls in it. But this time with those errors that I've posted recently. Although It's not an exception but still it's annoying having those message when the transitioningcontentcontrol content property changes.

I'm using MahApps.Metro 0.11.1.24

@punker76
Copy link
Member

@cod3n00b
first, how works your code behind code for the two grids?
sec, why not using ContentTemplate and ContentTemplateSelector for creating/showing your different grids at the TransitionContentControl? is it too dynamic?
third, try this little code

If traCreate.Content IsNot grdTransInfo Then
  traCreate.Content = null
  Call LoadTra....
  traCreate.Content = grdTransInfo
Else
  traCreate.Content = null
  Call LoadTra....
  traCreate.Content = grdTransPay

@cod3n00b
Copy link
Author

@punker76

First, I've created a module named Transaction. So it goes like this.

Public Module Transaction

    Public grdTransInfo As New Grid
    Public lblAssured As New Label
    Public lblAddress As New Label
    Public txtAssured As New TextBox
    Public txtAddress As New TextBox
    Public lblObligee As New Label
    Public lblObligeeAddress As New Label
    Public txtObligee As New TextBox



    Friend Sub LoadTransactionInfo()
        With lblAssured
            .Content = "Assured"
            .HorizontalAlignment = HorizontalAlignment.Left
            .Height = 28
            .VerticalAlignment = VerticalAlignment.Top
            .Width = 75
            .Margin = New Thickness(30, 32, 0, 0)
        End With

        With lblAddress
            .Content = "Address"
            .HorizontalAlignment = HorizontalAlignment.Left
            .Height = 28
            .VerticalAlignment = VerticalAlignment.Top
            .Width = 75
            .Margin = New Thickness(30, 65, 0, 0)
        End With

        With txtAssured
            .Text = vbNullString
            .HorizontalAlignment = HorizontalAlignment.Left
            .Margin = New Thickness(137, 34, 0, 0)
            .TextWrapping = TextWrapping.Wrap
            .VerticalAlignment = VerticalAlignment.Top
            .Width = 351
        End With

        With txtAddress
            .Text = vbNullString
            .HorizontalAlignment = HorizontalAlignment.Left
            .Height = 26
            .Margin = New Thickness(137, 67, 0, 0)
            .TextWrapping = TextWrapping.Wrap
            .VerticalAlignment = VerticalAlignment.Top
            .Width = 351
        End With

        With lblObligee
            .Content = "Obligee"
            .HorizontalAlignment = HorizontalAlignment.Left
            .Height = 28
            .VerticalAlignment = VerticalAlignment.Top
            .Width = 75
            .Margin = New Thickness(525, 32, 0, 0)
        End With

        With lblObligeeAddress
            .Content = "Address"
            .HorizontalAlignment = HorizontalAlignment.Left
            .Height = 28
            .VerticalAlignment = VerticalAlignment.Top
            .Width = 75
            .Margin = New Thickness(525, 65, 0, 0)
        End With

        With txtObligee
            .Text = vbNullString
            .HorizontalAlignment = HorizontalAlignment.Left
            .Height = 23
            .Margin = New Thickness(628, 34, 0, 0)
            .TextWrapping = TextWrapping.Wrap
            .VerticalAlignment = VerticalAlignment.Top
            .Width = 351
        End With

        ' Call the TransactionInfo to add all the controls to the grid as it's children.
        Call TransactionInfo()

    End Sub

    Friend Sub TransactionInfo()
        With grdTransInfo.Children
            .Add(lblAssured)
            .Add(lblAddress)
            .Add(txtAssured)
            .Add(txtAddress)
            .Add(lblObligee)
            .Add(lblObligeeAddress)
            .Add(txtObligee)
        End With
    End Sub

End Module

That's the code of my first grid(It's not the whole code actually). That's also my way in creating the second grid.
I've tried your third suggestion before I've posted my problem here but to no avail.
I'm new in WPF and I'm trying different ways to improve my skill.
I'll try your second suggestion and comment back here after I've tried it. Anyway, thank you for your help. :)

@cod3n00b
Copy link
Author

@punker76

I've tried your second suggestion. And I've found out that the TransitioningContentControl's ContentTemplateSelector property don't work. I have made a class that inherits the DataTemplateSelector and override the SelectTemplate function. I even try to make a break point in the opening line of the function itself but it doesn't go inside the function. I tried to switch from TransitioningContentControl to WPF's ContentControl (because the TransitioningContentControl inherits the ContentControl right?) and the ContentTemplateSelector property works in WPF's ContentControl.

I'm now using the latest alpha release of MahApps.Metro.
I'll post my codes later if needed.

@AzureKitsune
Copy link
Member

@cod3n00b I can take a quick look at the TransitioningContentControl and see why the ContentTemplateSelector isn't working.

Oh, off-topic and not trying to nitpick but... You don't have to use "Call" to call a method/function. You can simply write:

TransactionInfo()

@cod3n00b
Copy link
Author

@Amrykid

Oh, about that. I was aware of omitting the "Call" to call the method/function. But I'm used to it because I thought it's the best practice in calling a method. (I'm only using it in methods, not functions)
Thanks for clarifying.

Anyway, I hope it can be fixed soon if it isn't working.

@AzureKitsune
Copy link
Member

I am not sure how easy it would be to implement ContentTemplateSelector because I can't think of a scenario of where it would be useful. I'll need a scenario to test against.

AzureKitsune added a commit to AzureKitsune/MahApps.Metro that referenced this issue Oct 31, 2013
@cod3n00b
Copy link
Author

cod3n00b commented Nov 1, 2013

@Amrykid

What I did to test the ContentTemplateSelector before is when I clicked the Next button, it will change the Content property of the TransitioningContentControl to 0 or 1 (just to test what I've learned from self studying it). If the Content property is 0. It will use the first data template (with lots of textboxes, combo boxes, etc.) that I've created. If the Content property is 1 then, it will use the second template (which is actually just a button) to show if it will have its transition without giving me those annoying warnings in my immediate window.

Can I try that one you've referenced? Or is it included in the latest alpha release already?

@cod3n00b
Copy link
Author

cod3n00b commented Nov 1, 2013

@Amrykid @punker76

By the way, I forgot to mention that the TransitioningContentControl doesn't have a smooth transition when those annoying Resource Dictionary Warning 9 errors occurred while in transition. It does only occur when the content to be changed have some controls in it (e.g. some text boxes, combo boxes, labels, etc.). If the content to be changed have only few to none controls or doesn't generate the Resource Dictionary Warning 9 error it works smoothly.

That's what I have noticed. I thought before at first that it is because I'm not using ContentTemplate or ContentTemplateSelectors until I observe it once again.

@AzureKitsune
Copy link
Member

We will try to get this fixed before the next release.

@AzureKitsune AzureKitsune mentioned this issue Nov 14, 2013
15 tasks
@ghost ghost assigned AzureKitsune Nov 14, 2013
@AzureKitsune
Copy link
Member

I found an issue that is similar to this: #206

AzureKitsune added a commit to AzureKitsune/MahApps.Metro that referenced this issue Dec 16, 2013
@AzureKitsune
Copy link
Member

@cod3n00b If you're still around, could you check to see if PR #876 solves your problem?

AzureKitsune added a commit to AzureKitsune/MahApps.Metro that referenced this issue Dec 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants