.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani
Post New Web Links

syntax to specify subobject collection as xaml resource

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :JQuery
 

Sorry for the vague subject title.

A UserControl has an ObservableCollection

the UserControl is instantiated in MainWindow.xaml

I want to specify the collection defined within the usercontrol as a resource in MainWindow.xaml

I thought the syntax might be like the following

<Window.Resources>

<local:myUserControl.MyCollection x:key="whatever"/>

....

However this produces an error "The attachable property 'MyCollection' was not found in type 'myUserControl'

 

 

 




View Complete Post


More Related Resource Links

LinQ Syntax of looping a collection

  

Hi, I would be glad is there is anyone can point/teach me the correct way of iterate a collection in LINQ. I attached part of my coding for reference. I wish to find out the location(s) of an Employee who can also happen to be a Supervisor. My model contains a Many-to-Many relationship between Location and Employee. Thanks in advance

 

Dim someDataSource = From _e As Employee In _context.Employees
                                  Where _e.Locations = location <---- _e.Locations return a collection 
                                  Select _e.FullName, _e.ID


 


Initializing CommandBindings in XAML using a CommandBindingCollection static resource

  
Hi, I have defined a CommandBindingCollection object in <Window.Resources> and now I would like to use it as multiple controls' <Control.CommandBindings>.  Unfortunately, I can't find the right syntax. Any help will be appreciated. Thanks.  

2010 Collection class syntax/property problem

  
I converted a project from 2008 to 2010 to be able to use the TPL.

I've updated the compile target to .NET 4. Everything seems good, including the .NET 4 specific TPL stuff...except that:

Parallel.ForEach(MyClassCollection.Cast(Of MyClass), (Sub(ANYTHING As MYClass) ANYTHING.MySubRoutine()))

Gives the following as a syntax error:

Error 2 'Cast' is not a member of 'Microsoft.VisualBasic.Collection'. C:\Users\jeff\Documents\Visual Studio 2010\Projects\MyProject\MyProject\RunLoop.vb 229 34 MyProject

Any ideas?

Thanks.

How do I bind the ModelItem collection to combobox in XAML

  

Hi,

I need to create an custom activity with a combo box that need to display all the activity name within the same parent.

Below are the code snippets that failed to list out the activities name. Anyone has any ideas to make this work?

<ComboBox Name="ActivityList" 
  ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type sas:Sequence}},Path=ModelItem.Activities}"
  DisplayMemberPath="DisplayName"  
  SelectedValuePath="DisplayName"
 />

thanks.


Xaml cannot find StaticResource even sure the resource is defined

  

Hello,

I'm having trouble using static resources for color schemes in my user interface library. I have my Generic.xaml file, where I "include" all the other resource dictionary files:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

 <ResourceDictionary.MergedDictionaries>

  <ResourceDictionary Source="/Moonlite.Platform.Shell.UI;component/Themes/ColorSchemes/Default.xaml" />

etc.

using ImageSource collection in xaml (getting error Only public classes can be used in markup. 'Bit

  

Hy everybody, I made a custom control that has a property of type ObservableCollection<ImageSource>.

 

My problem is that if i use the control as is and set the list of frames from xaml everything works fine, but if I use my control as part of a template (for example a Button template) i get the error

 

" Only public classes can be used in markup. 'BitmapFrameDecode' type is not public.  "

I have no idea how to fix this..can anyone help me? Thank you very much!


Catalin Toma

using ImageSource collection in xaml (getting error Only public classes can be used in markup. 'Bit

  

Hy everybody, I made a custom control that has a property of type ObservableCollection<ImageSource>.

 

My problem is that if i use the control as is and set the list of frames from xaml everything works fine, but if I use my control as part of a template (for example a Button template) i get the error

 

This is my simplified control:

 

 

public partial class MultiFrameImage : UserControl
  {
    public MultiFrameImage()
    {
      ImageSources = new ObservableCollection<ImageSource>();

      InitializeComponent();
    }

    public ObservableCollection<ImageSource> ImageSources
    {
      get
      {
        return base.GetValue(ImageSourcesProperty) as ObservableCollection<ImageSource>;
      }
      set
      {
        base.SetValue(ImageSourcesProperty,value);
      }
    }
    public DependencyProperty ImageSourcesProperty = DependencyProperty.Register("ImageSources",typeof(ObservableCollection<ImageSource>),typeof(MultiFrameImage));
  }

 

Now,if I initialize the control like this everything works fine:

 

  <Grid>
    <me:MultiFrameImage>
      <me:MultiFrameImage.ImageSources>
        <ImageSource>/Resources/flow1.png</ImageSource>
        <ImageSource>/Reso

Is it possible to bind a xaml control's image source directly from the resource file ?

  

Hi all

 

Is it possible to bind a xaml control's image source directly from the resource file ?

 

BR

Bryan


What's new in XAML of .NET 4.0

  
With .NET 4.0 Microsoft will bring up a improved version of XAML. This arcitle shows you the language enhancements they made.
Easy Object References with {x:Reference}

Built-in Types

Generics in XAML with x:TypeArguments

Support for Arbitrary Dictionary Keys

Use of Non-Default Constructors with x:Arguments

Use of Static Factory Methods with x:FactoryMethod

Printing resource files

  

Hello,

I have some resource files for localization and would like to print them. When I try to print them in Visual Studio (with File -> Print...) the button is disabled. Does anyone know how to print them? (Without copying each into word or excel)


Thanks and regards,
Chris 


Need Syntax To Make Results of LINQ Union Return Non-Generic Type

  

Hi.

I have the below SQL which works just fine:

SELECT     Message, CreateDate, AccountId, AlertTypeId
FROM       dbo.Alerts
UNION
SELECT     TOP (100) PERCENT Status, CreateDate, AccountId,
                          (SELECT     10 AS Expr1) AS AlertTypeId
FROM         dbo.StatusUpdates
WHERE AccountId = PassedInParameter
ORDER BY CreateDate DESC

I have been going about trying to convert the above into a LINQ method and am having problems with return types.
As the above SQL illustrates, I am querying two distinct LINQ tables - Alerts and StatusUpdates -
and then attempting to perform a Union on them. In order to do the union in LINQ, I have to have agreeing types. So, I
am using "var" to make the results of "alerts" and "updates" generic before the union.  

public IList GetStatusUpdatesAsAlertsByAccountId<T>(Int32 accountId)
        {
            using (WorkbookDataContext dc = _conn.GetCont

set messageTemplateResourceName from resource file in Validation appication block.

  

Hi,


  I am using Validation application block in my project and want to set validation message from resource file, but not able to do that. I tried giving the path of resource file in messageTemplateResourceType and name of resource in messageTemplateResourceName. But it did not help as I only receive the message if I have set something in messageTemplate even after setting the resource file.

Here is my code:

<validator lowerBound="1" lowerBoundType="Inclusive" upperBound="250"
              upperBoundType="Inclusive" negated="false" messageTemplate=""
              messageTemplateResourceName="PerilTypeAndDetailsSection.VMEnterWhere"
              messageTemplateResourceType="Asurion.jCare.Common.Resources.UIResources.PerilTypeAndDetailsSection, Asurion.jCare.Common.Resources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
              tag="" type="Microsoft.Practices.EnterpriseLibrary.Validation.Validators.StringLengthValidator, Microsoft.Practices.Enterpris

how to make a css style background image be linked to an image in the resource file

  

hey guy, i need help in a very troubling matter. I want to make a textbox with a specific style, within this style a set of images as background parts, how can i attach these images to the custom control as whenever i take the .dll file and add it to the toolbar the images do not appear. So i tried to make them as resource files and their property as embedded in .resx file, so how to make the css style background image url to be linked to any of those image.


thanks in advance


Page Title from Resource file...

  

Hello,

I have Resource file...

I am using following code for Display Lable Text...

<asp:Label ID="lblName" runat="server" Text="<%$ Resources:resource,NAME %>"></asp:Label>

and I want to use that name for page title...

so I used "me.page.resources.resource.NAME" in code behind page.

 but I want to use that NAME in

<%@ Page Language="VB"

Problem in accessing resource file dynamically.

  

Steps I have followed are
1.I have created myres.en-GB.resx file at C:.
2.then created locale specific myres.en-GB.resources using resgen at c: only,
resgen c:\myres.en-GB.resx
3.Linked the Resource File to Assembly using AL.exe which is giving me assembly at c: only.
Al /t:lib /embed:myres.en-GB.resources /out:ClassLibrary1.dll
4.I have created one web application using vs 2008 & then build it.
5.Then placed both resource file & dll in web applications Bin\en-GB folder.
6.Anf finally written code at page load like
 CultureInfo info = new CultureInfo("en-GB");
            Thread.CurrentThread.CurrentCulture = info;
            Assembly asd = Assembly.Load("ClassLibrary1");
            ResourceManager res = new ResourceManager("myres.en-GB", asd.GetSatelliteAssembly(info));
            string sdf = res.GetString("Lab1");

but after running application I m getting following error
MissingManifestResourceException", "Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Cla

Can't read global resource in asp button

  


I have translated Text Ok in arabic and I have that placed in global Navig.resx file

<asp:Button ID

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

  

Hey guys


I came across this bug using while trying to implement a sitemap




Line 147:						Panel panel = new Panel();
Line 148:						panel.Controls.Add(_viewState);
Line 149:						Page.Form.Controls.Add(panel);
Line 150:						string script = "document.getElementById('" + _viewState.ClientID + "').value = GetViewState__AspNetTreeView('" + Extender.MakeChildId("UL") + "');";
Line 151:						Page.ClientScript.RegisterOnSubmitStatement(typeof(TreeViewAdapter), _viewState.ClientID, script);


[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +8696951
   CSSFriendly.TreeViewAdapter.SaveAdapterViewState() in E:\wwwroot\ThirdParty\CSSFriendly\CSSFriendly_24242\CSSFriendly\TreeViewAdapter.cs:149
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +8901848
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend