locked
XamlReader (gans) - 2/13/2008 9:38 AM PST RRS feed

  • Question

  • By: gans


    Hi guys,
    
    I'm working with styles and using the XamlReader, i can read Objects but not 
    Storyboards and Triggers.
    Why does that happen?
    
    thanks
    Friday, February 22, 2008 6:47 PM

All replies

  • By: Corrado Cavalli [MVP]


    Never tried with styles/triggers could you post a simple snippet of code?
    
    -- 
    Corrado Cavalli [Microsoft .NET MVP-MCP]
    UGIdotNET - http://www.ugidotnet.org
    Weblog: http://blogs.ugidotnet.org/corrado/
    
    Tuesday, February 26, 2008 1:32 AM
  • By: gans


    Public Sub _LoadImgSource(ByVal sArquivo As String, ByVal iImage As
    System.Windows.Controls.Image)
    If sArquivo = "Fix" Then
    Exit Sub
    End If

    Dim imgSource As New BitmapImage
    With imgSource
    .BeginInit()
    .UriSource = New Uri(sArquivo, UriKind.Absolute)
    .EndInit()
    End With

    If iImage Is Nothing Then
    iImage = New Image
    End If

    iImage.Source = imgSource
    End Sub

    Public Function _cloneElement(ByVal orig As UIElement) As UIElement
    If (orig Is Nothing) Then
    Return Nothing
    End If

    Dim s As String = XamlWriter.Save(orig)
    Dim sreader As StringReader = New StringReader(s)
    Dim xreader As XmlReader = XmlTextReader.Create(sreader, New
    XmlReaderSettings())

    Return CType(XamlReader.Load(xreader), UIElement)
    End Function

    Public Sub _LoadTelaBase(ByVal sDir As String, ByVal sFile As String, ByVal
    gGrid As Object)
    Dim xaml As FileStream = New FileStream(Replace(String.Concat(sDir,
    sFile), "file:\", ""), FileMode.Open, FileAccess.Read)

    Dim rootElement As Object = XamlReader.Load(xaml)

    gGrid.Resources = rootElement.Resources

    For vi As Integer = 0 To rootElement.Children.Count - 1
    If rootElement.Children.Item(vi).GetType.ToString() =
    "System.Windows.Controls.Image" Then
    Dim imgtemp As System.Windows.Controls.Image =
    CType(rootElement.Children.Item(vi), System.Windows.Controls.Image)

    If imgtemp.Tag.ToString <> "" Then
    _LoadImgSource(String.Concat(sDir, "\",
    imgtemp.Tag.ToString), imgtemp)
    End If
    End If


    gGrid.Children.Add(mo_principal._cloneElement(CType(rootElement.Children.Item(vi), UIElement)))
    Next

    rootElement = Nothing
    End Sub
    Tuesday, February 26, 2008 1:32 AM
  • By: gans


    Public Sub _LoadImgSource(ByVal sArquivo As String, ByVal iImage As 
    System.Windows.Controls.Image)
            If sArquivo = "Fix" Then
                Exit Sub
            End If
    
            Dim imgSource As New BitmapImage
            With imgSource
                .BeginInit()
                .UriSource = New Uri(sArquivo, UriKind.Absolute)
                .EndInit()
            End With
    
            If iImage Is Nothing Then
                iImage = New Image
            End If
    
            iImage.Source = imgSource
    End Sub
    
    Public Function _cloneElement(ByVal orig As UIElement) As UIElement
            If (orig Is Nothing) Then
                Return Nothing
            End If
    
            Dim s As String = XamlWriter.Save(orig)
            Dim sreader As StringReader = New StringReader(s)
            Dim xreader As XmlReader = XmlTextReader.Create(sreader, New 
    XmlReaderSettings())
    
            Return CType(XamlReader.Load(xreader), UIElement)
    End Function
    
    Public Sub _LoadTelaBase(ByVal sDir As String, ByVal sFile As String, ByVal 
    gGrid As Object)
            Dim xaml As FileStream = New FileStream(Replace(String.Concat(sDir, 
    sFile), "file:\", ""), FileMode.Open, FileAccess.Read)
    
            Dim rootElement As Object = XamlReader.Load(xaml)
    
            gGrid.Resources = rootElement.Resources
    
            For vi As Integer = 0 To rootElement.Children.Count - 1
                If rootElement.Children.Item(vi).GetType.ToString() = 
    "System.Windows.Controls.Image" Then
                    Dim imgtemp As System.Windows.Controls.Image = 
    CType(rootElement.Children.Item(vi), System.Windows.Controls.Image)
    
                    If imgtemp.Tag.ToString <> "" Then
                        _LoadImgSource(String.Concat(sDir, "\", 
    imgtemp.Tag.ToString), imgtemp)
                    End If
                End If
    
                
    gGrid.Children.Add(mo_principal._cloneElement(CType(rootElement.Children.Item(vi), UIElement)))
            Next
    
            rootElement = Nothing
        End Sub 
    Tuesday, February 26, 2008 1:34 AM