开发者

How to call a method or use a variable from a different namespace in another class in another namespace in a xaml file?

开发者 https://www.devze.com 2022-12-22 14:25 出处:网络
How to call 开发者_运维知识库a method or use a variable from a different namespace in another class in another namespace in a xaml file?You can add references to namespaces in your xaml root element l

How to call 开发者_运维知识库a method or use a variable from a different namespace in another class in another namespace in a xaml file?


You can add references to namespaces in your xaml root element like this...

<UserControl 
  x:Class="MySolution.MyNamespace.MyControl"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:another="clr-namespace:MySolution.AnotherNamespace">

You can then reference objects from within that namespace in your xaml, for example, I want to bind the Command property of my Button to a command in AnotherNamespace...

<Button Command="{x:Static another:MyCommand}"/>

I can't really offer much more help than that though without knowing what you actually hope to achieve.

0

精彩评论

暂无评论...
验证码 换一张
取 消